Skip to content

IComposition<TInterface> Interface

A live editing cursor over a family's members. Returned by Decompose<TInterface>(this IServiceCollection), it is an System.Collections.Generic.IList<> of the member descriptors backed directly by the service collection: inserting, removing or reordering through it mutates the family's registrations in place. A composed family's composite reads its members via GetKeyedServices at resolve time, so edits made through the cursor take effect with no separate recompose step - the members simply differ when the composite is finally resolved.

C#
public interface IComposition<in TInterface> : System.Collections.Generic.IList<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>, System.Collections.Generic.ICollection<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>, System.Collections.Generic.IEnumerable<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>, System.Collections.IEnumerable
    where TInterface : class

Type parameters

TInterface

The composed interface type.

Implements System.Collections.Generic.IList<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>, System.Collections.Generic.ICollection<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>, System.Collections.Generic.IEnumerable<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>, System.Collections.IEnumerable

Remarks

The position-aware editing methods live here rather than as extension methods so that TInterface is bound by the cursor and never repeated at the call site - only the anchor type is named (composition.AddAfter<ScopeValidator>(step)). Each returns the cursor, so edits chain, and each anchor is matched by implementation type, throwing when the anchor is not a member.

Methods

IComposition<TInterface>.AddAfter<TExisting>(ServiceDescriptor) Method

Inserts member immediately after the existing TExisting step.

C#
Abblix.DependencyInjection.IComposition<TInterface> AddAfter<TExisting>(Microsoft.Extensions.DependencyInjection.ServiceDescriptor member)
    where TExisting : TInterface;

Type parameters

TExisting

Parameters

member Microsoft.Extensions.DependencyInjection.ServiceDescriptor

Returns

Abblix.DependencyInjection.IComposition<TInterface>

IComposition<TInterface>.AddBefore<TExisting>(ServiceDescriptor) Method

Inserts member immediately before the existing TExisting step.

C#
Abblix.DependencyInjection.IComposition<TInterface> AddBefore<TExisting>(Microsoft.Extensions.DependencyInjection.ServiceDescriptor member)
    where TExisting : TInterface;

Type parameters

TExisting

Parameters

member Microsoft.Extensions.DependencyInjection.ServiceDescriptor

Returns

Abblix.DependencyInjection.IComposition<TInterface>

IComposition<TInterface>.AddFirst(ServiceDescriptor) Method

Inserts member as the first step of the family.

C#
Abblix.DependencyInjection.IComposition<TInterface> AddFirst(Microsoft.Extensions.DependencyInjection.ServiceDescriptor member);

Parameters

member Microsoft.Extensions.DependencyInjection.ServiceDescriptor

Returns

Abblix.DependencyInjection.IComposition<TInterface>

IComposition<TInterface>.AddLast(ServiceDescriptor) Method

Ensures member is in the family, appending it as the last step when it is not. A member already there stays where it is: a family holds one member per implementation type, so there is nothing to add and no second copy to place.

C#
Abblix.DependencyInjection.IComposition<TInterface> AddLast(Microsoft.Extensions.DependencyInjection.ServiceDescriptor member);

Parameters

member Microsoft.Extensions.DependencyInjection.ServiceDescriptor

Returns

Abblix.DependencyInjection.IComposition<TInterface>

IComposition<TInterface>.Remove<TExisting>() Method

Removes the existing TExisting step from the family.

C#
Abblix.DependencyInjection.IComposition<TInterface> Remove<TExisting>()
    where TExisting : TInterface;

Type parameters

TExisting

Returns

Abblix.DependencyInjection.IComposition<TInterface>

IComposition<TInterface>.Replace<TExisting>(ServiceDescriptor) Method

Replaces the existing TExisting step with member, keeping its position.

C#
Abblix.DependencyInjection.IComposition<TInterface> Replace<TExisting>(Microsoft.Extensions.DependencyInjection.ServiceDescriptor member)
    where TExisting : TInterface;

Type parameters

TExisting

Parameters

member Microsoft.Extensions.DependencyInjection.ServiceDescriptor

Returns

Abblix.DependencyInjection.IComposition<TInterface>