#### [Abblix\.DependencyInjection](https://www.abblix.com/en/docs/api/abblix-dependencyinjection 'index')
### [Abblix\.DependencyInjection](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection 'Abblix\.DependencyInjection')

## ServiceCollectionExtensions Class

Provides extension methods for [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') to enhance dependency injection capabilities\.

```csharp
public static class ServiceCollectionExtensions
```

Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → ServiceCollectionExtensions
### Methods

## ServiceCollectionExtensions\.AddAlias\<TService,TImplementation\>\(this IServiceCollection\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection)}

Creates an alias registration that allows resolving a service through a different interface or type\.

```csharp
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAlias<TService,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services)
    where TService : class
    where TImplementation : class, TService;
```
#### Type parameters

###### `TService` {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TService}

The service type for the alias registration\.

###### `TImplementation` {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TImplementation}

The implementation service type that is already registered\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).services}

The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') to add the service to\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')  
The updated [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
Thrown when no registration is found for [TImplementation](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.AddAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TImplementation 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.AddAlias\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)\.TImplementation')\.

### Remarks

This method creates an alias by cloning the source service descriptor with a new service type.
The alias preserves the lifetime of the source registration (Singleton, Scoped, or Transient).

For Singleton lifetime with factory-based registrations, ensures the same instance is returned
when resolving through either the source type or the alias. For Scoped and Transient lifetimes,
the alias resolves through the source service to maintain proper lifetime semantics.

Supports both interface-to-interface aliasing (e.g., `AddAlias<IBase, IPrimary>()`)
and interface-to-implementation aliasing (e.g., `AddAlias<IService, ServiceImpl>()`).

When multiple different source services are aliased to the same target interface,
`IEnumerable<TService>` resolution returns instances from all aliases.

## ServiceCollectionExtensions\.AddKeyedAlias\<TService,TSource\>\(this IServiceCollection, object, object\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object)}

Creates a keyed alias registration that allows resolving a service through a different interface or type with a specific key\.

```csharp
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddKeyedAlias<TService,TSource>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, object? serviceKey, object? sourceKey=null)
    where TService : class
    where TSource : class;
```
#### Type parameters

###### `TService` {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object).TService}

The service type for the alias registration\.

###### `TSource` {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object).TSource}

The source service type that is already registered\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object).services}

The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') to add the service to\.

###### `serviceKey` [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object).serviceKey}

The service key to associate with the alias\.

###### `sourceKey` [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object).sourceKey}

The service key of the source registration\. Use null for non\-keyed source\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')  
The updated [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
Thrown when no registration is found for [TSource](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.AddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object).TSource 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.AddKeyedAlias\<TService,TSource\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, object, object\)\.TSource') with the specified [sourceKey](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.AddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object).sourceKey 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.AddKeyedAlias\<TService,TSource\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, object, object\)\.sourceKey')\.

### Remarks

This method creates a keyed alias by cloning the source service descriptor with a new service type and key.
The alias preserves the lifetime of the source registration (Singleton, Scoped, or Transient).

For factory-based registrations, the alias resolves through the source service to maintain proper lifetime semantics.

## ServiceCollectionExtensions\.AddScoped\<T\>\(this IServiceCollection, Dependency\[\]\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddScoped_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[])}

Registers a scoped service of the type specified in [T](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.AddScoped_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).T 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.AddScoped\<T\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, Abblix\.DependencyInjection\.Dependency\[\]\)\.T') with custom dependencies\.
A scoped service is created once per request within the scope\.

```csharp
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScoped<T>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, params Abblix.DependencyInjection.Dependency[] dependencies)
    where T : class;
```
#### Type parameters

###### `T` {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddScoped_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).T}

The type of the service to add\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddScoped_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).services}

The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') to add the service to\.

###### `dependencies` [Dependency](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.Dependency 'Abblix\.DependencyInjection\.Dependency')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddScoped_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).dependencies}

An array of [Dependency](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.Dependency 'Abblix\.DependencyInjection\.Dependency') objects representing additional dependencies
            required by the service\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')  
The updated [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')\.

## ServiceCollectionExtensions\.AddScoped\<TService,TImplementation\>\(this IServiceCollection, Dependency\[\]\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddScoped_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[])}

Registers a scoped service with the implementation type specified in [TImplementation](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.AddScoped_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).TImplementation 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.AddScoped\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, Abblix\.DependencyInjection\.Dependency\[\]\)\.TImplementation')
and the service type specified in [TService](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.AddScoped_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).TService 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.AddScoped\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, Abblix\.DependencyInjection\.Dependency\[\]\)\.TService') with custom dependencies\.
A scoped service is created once per request within the scope\.

```csharp
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScoped<TService,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, params Abblix.DependencyInjection.Dependency[] dependencies)
    where TService : class
    where TImplementation : class, TService;
```
#### Type parameters

###### `TService` {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddScoped_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).TService}

The type of the service to add\.

###### `TImplementation` {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddScoped_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).TImplementation}

The type of the implementation to use\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddScoped_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).services}

The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') to add the service to\.

###### `dependencies` [Dependency](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.Dependency 'Abblix\.DependencyInjection\.Dependency')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddScoped_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).dependencies}

An array of [Dependency](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.Dependency 'Abblix\.DependencyInjection\.Dependency') objects representing additional dependencies
            required by the service\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')  
The updated [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')\.

## ServiceCollectionExtensions\.AddSingleton\<T\>\(this IServiceCollection, Dependency\[\]\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddSingleton_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[])}

Registers a singleton service of the type specified in [T](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.AddSingleton_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).T 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.AddSingleton\<T\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, Abblix\.DependencyInjection\.Dependency\[\]\)\.T') with custom dependencies\.
A singleton service is created the first time it is requested, and subsequent requests use the same instance\.

```csharp
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddSingleton<T>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, params Abblix.DependencyInjection.Dependency[] dependencies)
    where T : class;
```
#### Type parameters

###### `T` {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddSingleton_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).T}

The type of the service to add\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddSingleton_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).services}

The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') to add the service to\.

###### `dependencies` [Dependency](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.Dependency 'Abblix\.DependencyInjection\.Dependency')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddSingleton_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).dependencies}

An array of [Dependency](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.Dependency 'Abblix\.DependencyInjection\.Dependency') objects representing additional dependencies
            required by the service\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')  
The updated [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')\.

## ServiceCollectionExtensions\.AddSingleton\<TService,TImplementation\>\(this IServiceCollection, Dependency\[\]\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddSingleton_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[])}

Registers a singleton service with the implementation type specified in [TImplementation](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.AddSingleton_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).TImplementation 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.AddSingleton\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, Abblix\.DependencyInjection\.Dependency\[\]\)\.TImplementation')
and the service type specified in [TService](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.AddSingleton_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).TService 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.AddSingleton\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, Abblix\.DependencyInjection\.Dependency\[\]\)\.TService') with custom dependencies\.

```csharp
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddSingleton<TService,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, params Abblix.DependencyInjection.Dependency[] dependencies)
    where TService : class
    where TImplementation : class, TService;
```
#### Type parameters

###### `TService` {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddSingleton_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).TService}

The type of the service to add\.

###### `TImplementation` {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddSingleton_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).TImplementation}

The type of the implementation to use\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddSingleton_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).services}

The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') to add the service to\.

###### `dependencies` [Dependency](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.Dependency 'Abblix\.DependencyInjection\.Dependency')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddSingleton_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).dependencies}

An array of [Dependency](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.Dependency 'Abblix\.DependencyInjection\.Dependency') objects representing additional dependencies
            required by the service\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')  
The updated [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')\.

## ServiceCollectionExtensions\.AddTransient\<T\>\(this IServiceCollection, Dependency\[\]\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddTransient_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[])}

Registers a transient service of the type specified in [T](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.AddTransient_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).T 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.AddTransient\<T\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, Abblix\.DependencyInjection\.Dependency\[\]\)\.T') with custom dependencies\.
Transient services are created each time they are requested\.

```csharp
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddTransient<T>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, params Abblix.DependencyInjection.Dependency[] dependencies)
    where T : class;
```
#### Type parameters

###### `T` {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddTransient_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).T}

The service type to register\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddTransient_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).services}

The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') to add the service to\.

###### `dependencies` [Dependency](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.Dependency 'Abblix\.DependencyInjection\.Dependency')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddTransient_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).dependencies}

The dependencies required by the service\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')  
The updated [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')\.

### Remarks
This overload is useful when the service type and implementation type are the same\.

## ServiceCollectionExtensions\.AddTransient\<TService,TImplementation\>\(this IServiceCollection, Dependency\[\]\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddTransient_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[])}

Registers a transient service with the implementation type specified in [TImplementation](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.AddTransient_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).TImplementation 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.AddTransient\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, Abblix\.DependencyInjection\.Dependency\[\]\)\.TImplementation')
and the service type specified in [TService](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.AddTransient_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).TService 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.AddTransient\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, Abblix\.DependencyInjection\.Dependency\[\]\)\.TService') with custom dependencies\.
Transient services are created each time they are requested\.

```csharp
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddTransient<TService,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, params Abblix.DependencyInjection.Dependency[] dependencies)
    where TService : class
    where TImplementation : class, TService;
```
#### Type parameters

###### `TService` {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddTransient_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).TService}

The type of the service to add\.

###### `TImplementation` {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddTransient_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).TImplementation}

The type of the implementation to use\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddTransient_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).services}

The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') to add the service to\.

###### `dependencies` [Dependency](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.Dependency 'Abblix\.DependencyInjection\.Dependency')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') {#Abblix.DependencyInjection.ServiceCollectionExtensions.AddTransient_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).dependencies}

The dependencies required by the service\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')  
The updated [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')\.

## ServiceCollectionExtensions\.ChangeLifetime\<T\>\(this IServiceCollection, ServiceLifetime\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.ChangeLifetime_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Microsoft.Extensions.DependencyInjection.ServiceLifetime)}

Changes the lifetime of a registered service of type [T](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.ChangeLifetime_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Microsoft.Extensions.DependencyInjection.ServiceLifetime).T 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.ChangeLifetime\<T\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, Microsoft\.Extensions\.DependencyInjection\.ServiceLifetime\)\.T')
to the specified [lifetime](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.ChangeLifetime_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Microsoft.Extensions.DependencyInjection.ServiceLifetime).lifetime 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.ChangeLifetime\<T\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, Microsoft\.Extensions\.DependencyInjection\.ServiceLifetime\)\.lifetime')\.

```csharp
public static Microsoft.Extensions.DependencyInjection.IServiceCollection ChangeLifetime<T>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Microsoft.Extensions.DependencyInjection.ServiceLifetime lifetime);
```
#### Type parameters

###### `T` {#Abblix.DependencyInjection.ServiceCollectionExtensions.ChangeLifetime_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Microsoft.Extensions.DependencyInjection.ServiceLifetime).T}

The service type whose lifetime is to be changed\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.ChangeLifetime_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Microsoft.Extensions.DependencyInjection.ServiceLifetime).services}

The service collection to operate on\.

###### `lifetime` [Microsoft\.Extensions\.DependencyInjection\.ServiceLifetime](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicelifetime 'Microsoft\.Extensions\.DependencyInjection\.ServiceLifetime') {#Abblix.DependencyInjection.ServiceCollectionExtensions.ChangeLifetime_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Microsoft.Extensions.DependencyInjection.ServiceLifetime).lifetime}

The new [Microsoft\.Extensions\.DependencyInjection\.ServiceLifetime](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicelifetime 'Microsoft\.Extensions\.DependencyInjection\.ServiceLifetime') to apply\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')  
The modified [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') instance\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
Thrown if the service descriptor for [T](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.ChangeLifetime_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Microsoft.Extensions.DependencyInjection.ServiceLifetime).T 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.ChangeLifetime\<T\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, Microsoft\.Extensions\.DependencyInjection\.ServiceLifetime\)\.T') has an unexpected format\.

### Remarks
Useful when you need to override the lifetime of an existing registration \(e\.g\., from Singleton to Scoped\)\.

## ServiceCollectionExtensions\.Clone\(this ServiceDescriptor, Type\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.Clone(thisMicrosoft.Extensions.DependencyInjection.ServiceDescriptor,System.Type)}

Creates a copy of the service descriptor with a different service type while preserving
the implementation and lifetime\. For factory\-based registrations, resolves through the
source service type to maintain same\-instance semantics across all aliases\.

```csharp
public static Microsoft.Extensions.DependencyInjection.ServiceDescriptor Clone(this Microsoft.Extensions.DependencyInjection.ServiceDescriptor source, System.Type serviceType);
```
#### Parameters

###### `source` [Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicedescriptor 'Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor') {#Abblix.DependencyInjection.ServiceCollectionExtensions.Clone(thisMicrosoft.Extensions.DependencyInjection.ServiceDescriptor,System.Type).source}

The source service descriptor to clone\.

###### `serviceType` [System\.Type](https://learn.microsoft.com/en-us/dotnet/api/system.type 'System\.Type') {#Abblix.DependencyInjection.ServiceCollectionExtensions.Clone(thisMicrosoft.Extensions.DependencyInjection.ServiceDescriptor,System.Type).serviceType}

The service type for the cloned descriptor\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicedescriptor 'Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor')  
A new service descriptor with the specified service type\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
Thrown when the source descriptor has an invalid configuration\.

## ServiceCollectionExtensions\.CloneKeyed\(this ServiceDescriptor, Type, object\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.CloneKeyed(thisMicrosoft.Extensions.DependencyInjection.ServiceDescriptor,System.Type,object)}

Creates a copy of the keyed service descriptor with a different service type and key while preserving
the implementation and lifetime\. For factory\-based registrations, resolves through the
source service type and key to maintain same\-instance semantics across all aliases\.

```csharp
public static Microsoft.Extensions.DependencyInjection.ServiceDescriptor CloneKeyed(this Microsoft.Extensions.DependencyInjection.ServiceDescriptor source, System.Type serviceType, object? serviceKey);
```
#### Parameters

###### `source` [Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicedescriptor 'Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor') {#Abblix.DependencyInjection.ServiceCollectionExtensions.CloneKeyed(thisMicrosoft.Extensions.DependencyInjection.ServiceDescriptor,System.Type,object).source}

The source service descriptor to clone\.

###### `serviceType` [System\.Type](https://learn.microsoft.com/en-us/dotnet/api/system.type 'System\.Type') {#Abblix.DependencyInjection.ServiceCollectionExtensions.CloneKeyed(thisMicrosoft.Extensions.DependencyInjection.ServiceDescriptor,System.Type,object).serviceType}

The service type for the cloned descriptor\.

###### `serviceKey` [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') {#Abblix.DependencyInjection.ServiceCollectionExtensions.CloneKeyed(thisMicrosoft.Extensions.DependencyInjection.ServiceDescriptor,System.Type,object).serviceKey}

The service key for the cloned descriptor\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicedescriptor 'Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor')  
A new keyed service descriptor with the specified service type and key\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
Thrown when the source descriptor has an invalid configuration\.

## ServiceCollectionExtensions\.Compose\<TInterface,TComposite\>\(this IServiceCollection, Dependency\[\]\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.Compose_TInterface,TComposite_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[])}

Composes a service type with multiple implementations into a single composite service\.

```csharp
public static Microsoft.Extensions.DependencyInjection.IServiceCollection Compose<TInterface,TComposite>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, params Abblix.DependencyInjection.Dependency[] dependencies)
    where TInterface : class
    where TComposite : class, TInterface;
```
#### Type parameters

###### `TInterface` {#Abblix.DependencyInjection.ServiceCollectionExtensions.Compose_TInterface,TComposite_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).TInterface}

The interface type to be composed\.

###### `TComposite` {#Abblix.DependencyInjection.ServiceCollectionExtensions.Compose_TInterface,TComposite_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).TComposite}

The composite implementation type\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.Compose_TInterface,TComposite_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).services}

The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') to add the service to\.

###### `dependencies` [Dependency](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.Dependency 'Abblix\.DependencyInjection\.Dependency')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') {#Abblix.DependencyInjection.ServiceCollectionExtensions.Compose_TInterface,TComposite_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).dependencies}

The dependencies required by the composite service\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')  
The updated [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')\.

### Remarks
This method replaces the registrations of a service type with a single composite registration over them\.
The composite type must have a constructor that accepts an array of the interface type\.
The existing registrations move to keyed ones that the composite resolves in registration order; being
keyed also hides them from plain resolution, so the singular resolve yields only the composite\. Their key
is private to this library and deliberately unnamed here: a key written down in documentation goes stale,
and a stale key answers a lookup with an empty sequence rather than an error\. The family thus remains descriptor data in the collection
rather than a snapshot captured in a closure: [Decompose&lt;TInterface&gt;\(this IServiceCollection\)](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.Decompose_TInterface_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection) 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.Decompose\<TInterface\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)') returns a live cursor
over that data, and edits through it reach the composite at resolve \- without the host ever naming the
composite type\. Members keep their own lifetimes and the composite adopts the shortest among them, so a
longer\-lived member is simply shared; only a member shorter\-lived than the composite is rejected, since
a composite may not capture something that dies before it\.

## ServiceCollectionExtensions\.ComposeKeyed\<TInterface,TComposite\>\(this IServiceCollection, object, Dependency\[\]\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.ComposeKeyed_TInterface,TComposite_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,Abblix.DependencyInjection.Dependency[])}

Composes keyed implementations of [TInterface](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.ComposeKeyed_TInterface,TComposite_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,Abblix.DependencyInjection.Dependency[]).TInterface 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.ComposeKeyed\<TInterface,TComposite\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, object, Abblix\.DependencyInjection\.Dependency\[\]\)\.TInterface') registered under
[serviceKey](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.ComposeKeyed_TInterface,TComposite_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,Abblix.DependencyInjection.Dependency[]).serviceKey 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.ComposeKeyed\<TInterface,TComposite\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, object, Abblix\.DependencyInjection\.Dependency\[\]\)\.serviceKey') into a single composite resolvable under that same key \- the keyed
counterpart of [Compose&lt;TInterface,TComposite&gt;\(this IServiceCollection, Dependency\[\]\)](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.Compose_TInterface,TComposite_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]) 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.Compose\<TInterface,TComposite\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, Abblix\.DependencyInjection\.Dependency\[\]\)')\.
The members move to keyed registrations under the family's own key, so same\-interface families under
different keys stay isolated and the family remains editable descriptor data for
[DecomposeKeyed&lt;TInterface&gt;\(this IServiceCollection, object\)](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.DecomposeKeyed_TInterface_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object) 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.DecomposeKeyed\<TInterface\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, object\)')\.

```csharp
public static Microsoft.Extensions.DependencyInjection.IServiceCollection ComposeKeyed<TInterface,TComposite>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, object serviceKey, params Abblix.DependencyInjection.Dependency[] dependencies)
    where TInterface : class
    where TComposite : class, TInterface;
```
#### Type parameters

###### `TInterface` {#Abblix.DependencyInjection.ServiceCollectionExtensions.ComposeKeyed_TInterface,TComposite_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,Abblix.DependencyInjection.Dependency[]).TInterface}

The interface type to be composed\.

###### `TComposite` {#Abblix.DependencyInjection.ServiceCollectionExtensions.ComposeKeyed_TInterface,TComposite_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,Abblix.DependencyInjection.Dependency[]).TComposite}

The composite implementation type\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.ComposeKeyed_TInterface,TComposite_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,Abblix.DependencyInjection.Dependency[]).services}

The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') to add the service to\.

###### `serviceKey` [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') {#Abblix.DependencyInjection.ServiceCollectionExtensions.ComposeKeyed_TInterface,TComposite_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,Abblix.DependencyInjection.Dependency[]).serviceKey}

The service key whose registrations form the family\.

###### `dependencies` [Dependency](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.Dependency 'Abblix\.DependencyInjection\.Dependency')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') {#Abblix.DependencyInjection.ServiceCollectionExtensions.ComposeKeyed_TInterface,TComposite_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,Abblix.DependencyInjection.Dependency[]).dependencies}

The dependencies required by the composite service\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')  
The updated [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
The family is already composed under this key\.

## ServiceCollectionExtensions\.CreateService\(this IServiceProvider, Type, Dependency\[\]\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.CreateService(thisSystem.IServiceProvider,System.Type,Abblix.DependencyInjection.Dependency[])}

Creates an instance of the specified type using the provided dependencies\.

```csharp
public static object CreateService(this System.IServiceProvider serviceProvider, System.Type type, params Abblix.DependencyInjection.Dependency[] dependencies);
```
#### Parameters

###### `serviceProvider` [System\.IServiceProvider](https://learn.microsoft.com/en-us/dotnet/api/system.iserviceprovider 'System\.IServiceProvider') {#Abblix.DependencyInjection.ServiceCollectionExtensions.CreateService(thisSystem.IServiceProvider,System.Type,Abblix.DependencyInjection.Dependency[]).serviceProvider}

The service provider to resolve required services from\.

###### `type` [System\.Type](https://learn.microsoft.com/en-us/dotnet/api/system.type 'System\.Type') {#Abblix.DependencyInjection.ServiceCollectionExtensions.CreateService(thisSystem.IServiceProvider,System.Type,Abblix.DependencyInjection.Dependency[]).type}

The type of service to create\.

###### `dependencies` [Dependency](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.Dependency 'Abblix\.DependencyInjection\.Dependency')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') {#Abblix.DependencyInjection.ServiceCollectionExtensions.CreateService(thisSystem.IServiceProvider,System.Type,Abblix.DependencyInjection.Dependency[]).dependencies}

A list of explicitly provided dependencies\.

#### Returns
[System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object')  
An instance of the specified [type](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.CreateService(thisSystem.IServiceProvider,System.Type,Abblix.DependencyInjection.Dependency[]).type 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.CreateService\(this System\.IServiceProvider, System\.Type, Abblix\.DependencyInjection\.Dependency\[\]\)\.type')\.

### Remarks
This method allows partial control over dependency injection by mixing resolved and custom parameters\.
Useful in plugin scenarios, factory setups, or advanced test setups\.

## ServiceCollectionExtensions\.CreateService\<T\>\(this IServiceProvider, Dependency\[\]\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.CreateService_T_(thisSystem.IServiceProvider,Abblix.DependencyInjection.Dependency[])}

Creates an instance of the specified service type [T](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.CreateService_T_(thisSystem.IServiceProvider,Abblix.DependencyInjection.Dependency[]).T 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.CreateService\<T\>\(this System\.IServiceProvider, Abblix\.DependencyInjection\.Dependency\[\]\)\.T') using the provided dependencies\.

```csharp
public static T CreateService<T>(this System.IServiceProvider serviceProvider, params Abblix.DependencyInjection.Dependency[] dependencies);
```
#### Type parameters

###### `T` {#Abblix.DependencyInjection.ServiceCollectionExtensions.CreateService_T_(thisSystem.IServiceProvider,Abblix.DependencyInjection.Dependency[]).T}

The type of service to create\.
#### Parameters

###### `serviceProvider` [System\.IServiceProvider](https://learn.microsoft.com/en-us/dotnet/api/system.iserviceprovider 'System\.IServiceProvider') {#Abblix.DependencyInjection.ServiceCollectionExtensions.CreateService_T_(thisSystem.IServiceProvider,Abblix.DependencyInjection.Dependency[]).serviceProvider}

The service provider to resolve required services from\.

###### `dependencies` [Dependency](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.Dependency 'Abblix\.DependencyInjection\.Dependency')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') {#Abblix.DependencyInjection.ServiceCollectionExtensions.CreateService_T_(thisSystem.IServiceProvider,Abblix.DependencyInjection.Dependency[]).dependencies}

A list of explicitly provided dependencies\.

#### Returns
[T](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.CreateService_T_(thisSystem.IServiceProvider,Abblix.DependencyInjection.Dependency[]).T 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.CreateService\<T\>\(this System\.IServiceProvider, Abblix\.DependencyInjection\.Dependency\[\]\)\.T')  
An instance of type [T](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.CreateService_T_(thisSystem.IServiceProvider,Abblix.DependencyInjection.Dependency[]).T 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.CreateService\<T\>\(this System\.IServiceProvider, Abblix\.DependencyInjection\.Dependency\[\]\)\.T')\.

### Remarks
This overload simplifies strongly typed creation of services with custom dependency injection\.

## ServiceCollectionExtensions\.Decompose\<TInterface\>\(this IServiceCollection\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.Decompose_TInterface_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection)}

Opens the [TInterface](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.Decompose_TInterface_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TInterface 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.Decompose\<TInterface\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)\.TInterface') family for in\-place editing: returns a live
[IComposition&lt;TInterface&gt;](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.IComposition_TInterface_ 'Abblix\.DependencyInjection\.IComposition\<TInterface\>') cursor over its members\. Insert, remove or reorder through the
cursor and the change is live \- a composed family's composite reads its members via
`GetKeyedServices` at resolve, so the edit takes effect with no separate recompose\.

```csharp
public static Abblix.DependencyInjection.IComposition<TInterface> Decompose<TInterface>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services)
    where TInterface : class;
```
#### Type parameters

###### `TInterface` {#Abblix.DependencyInjection.ServiceCollectionExtensions.Decompose_TInterface_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TInterface}

The family interface type\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.Decompose_TInterface_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).services}

The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') holding the family\.

#### Returns
[Abblix\.DependencyInjection\.IComposition&lt;](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.IComposition_TInterface_ 'Abblix\.DependencyInjection\.IComposition\<TInterface\>')[TInterface](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.Decompose_TInterface_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TInterface 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.Decompose\<TInterface\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)\.TInterface')[&gt;](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.IComposition_TInterface_ 'Abblix\.DependencyInjection\.IComposition\<TInterface\>')  
A live cursor over the family's members, in execution order\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
The family is composed but what a composition leaves behind
            is no longer intact \- either the mark over its members or the composite that heads them has been removed
            from the collection\. No sequence of calls on this API produces that\.

### Remarks
Whether the family has been composed is the cursor's business, not the caller's: editing its members is
the only reason to ask for one\. Composed, the members live as keyed descriptors under a key private to
this library, which hides them from plain resolution; this cursor and its resolve\-time counterpart
[Decompose&lt;TInterface&gt;\(this IServiceProvider, object\)](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.Decompose_TInterface_(thisSystem.IServiceProvider,object) 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.Decompose\<TInterface\>\(this System\.IServiceProvider, object\)') are the only ways to reach them\. Uncomposed,
they are the plain descriptors of the interface, and a later `Compose` takes them as they stand\. The cursor edits whichever of the two the family currently holds, so the same call adds a
member before and after composition\.
[IComposition&lt;TInterface&gt;](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.IComposition_TInterface_ 'Abblix\.DependencyInjection\.IComposition\<TInterface\>') adds position\-aware sugar \(`AddAfter`, `AddBefore`,
`Remove`, \.\.\.\); anchors are matched by implementation type via
[ResolveImplementationType\(this ServiceDescriptor\)](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.ResolveImplementationType(thisMicrosoft.Extensions.DependencyInjection.ServiceDescriptor) 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.ResolveImplementationType\(this Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor\)'), which identifies a member even when it was registered through a
typed factory \(e\.g\. by [TryAddEnumerableAlias&lt;TService,TImplementation&gt;\(this IServiceCollection\)](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddEnumerableAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection) 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.TryAddEnumerableAlias\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)')\)\.

```csharp
services.Decompose<IPipelineStep>()
    .AddAfter<BuiltInStep>(ServiceDescriptor.Singleton<IPipelineStep, MyStep>())
    .Remove<UnwantedStep>();
```

## ServiceCollectionExtensions\.Decompose\<TInterface\>\(this IServiceProvider, object\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.Decompose_TInterface_(thisSystem.IServiceProvider,object)}

The members of the [TInterface](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.Decompose_TInterface_(thisSystem.IServiceProvider,object).TInterface 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.Decompose\<TInterface\>\(this System\.IServiceProvider, object\)\.TInterface') family as the container will run them \- the
resolve\-time counterpart of [Decompose&lt;TInterface&gt;\(this IServiceCollection\)](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.Decompose_TInterface_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection) 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.Decompose\<TInterface\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)'), which edits the
same family before the container is built\.

```csharp
public static System.Collections.Generic.IReadOnlyList<TInterface> Decompose<TInterface>(this System.IServiceProvider serviceProvider, object? serviceKey=null)
    where TInterface : class;
```
#### Type parameters

###### `TInterface` {#Abblix.DependencyInjection.ServiceCollectionExtensions.Decompose_TInterface_(thisSystem.IServiceProvider,object).TInterface}

The family interface\.
#### Parameters

###### `serviceProvider` [System\.IServiceProvider](https://learn.microsoft.com/en-us/dotnet/api/system.iserviceprovider 'System\.IServiceProvider') {#Abblix.DependencyInjection.ServiceCollectionExtensions.Decompose_TInterface_(thisSystem.IServiceProvider,object).serviceProvider}

The provider built from the collection the family lives in\.

###### `serviceKey` [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') {#Abblix.DependencyInjection.ServiceCollectionExtensions.Decompose_TInterface_(thisSystem.IServiceProvider,object).serviceKey}

The key a keyed family lives under, or null for a plain family\.

#### Returns
[System\.Collections\.Generic\.IReadOnlyList&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlylist-1 'System\.Collections\.Generic\.IReadOnlyList\`1')[TInterface](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.Decompose_TInterface_(thisSystem.IServiceProvider,object).TInterface 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.Decompose\<TInterface\>\(this System\.IServiceProvider, object\)\.TInterface')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlylist-1 'System\.Collections\.Generic\.IReadOnlyList\`1')  
The family's members, in execution order\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
The family has no members\.

### Remarks
Whether the family was composed is this method's business, not the caller's: composed, the members are
keyed and hidden from plain resolution; loose, they are the plain registrations\. Asking for them by the
key composition happens to use is what a caller must not do, because a key that is merely out of date
answers with an empty set rather than an error \- and an empty set reads as a family with nothing in it\.

For that reason an empty family is refused rather than returned. A caller that wants a possibly-empty
answer is asking about registrations rather than about a family, and
[Microsoft\.Extensions\.DependencyInjection\.ServiceProviderServiceExtensions\.GetServices&lt;&gt;\.IServiceProvider\)](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.serviceproviderserviceextensions.getservices--1#microsoft-extensions-dependencyinjection-serviceproviderserviceextensions-getservices--1(system-iserviceprovider) 'Microsoft\.Extensions\.DependencyInjection\.ServiceProviderServiceExtensions\.GetServices\`\`1\(System\.IServiceProvider\)') is that question.

## ServiceCollectionExtensions\.DecomposeKeyed\<TInterface\>\(this IServiceCollection, object\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.DecomposeKeyed_TInterface_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object)}

Opens the keyed [TInterface](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.DecomposeKeyed_TInterface_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object).TInterface 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.DecomposeKeyed\<TInterface\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, object\)\.TInterface') family for in\-place editing: returns a live
[IComposition&lt;TInterface&gt;](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.IComposition_TInterface_ 'Abblix\.DependencyInjection\.IComposition\<TInterface\>') cursor over its members\. Insert, remove or reorder through the
cursor and the change is live \- a composed family's keyed composite reads its members via
`GetKeyedServices` at resolve, so the edit takes effect with no separate recompose\. Uncomposed, the
members are the descriptors registered under the service key itself, and the cursor edits those\.

```csharp
public static Abblix.DependencyInjection.IComposition<TInterface> DecomposeKeyed<TInterface>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, object serviceKey)
    where TInterface : class;
```
#### Type parameters

###### `TInterface` {#Abblix.DependencyInjection.ServiceCollectionExtensions.DecomposeKeyed_TInterface_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object).TInterface}

The composed interface type\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.DecomposeKeyed_TInterface_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object).services}

The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') holding the composed family\.

###### `serviceKey` [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') {#Abblix.DependencyInjection.ServiceCollectionExtensions.DecomposeKeyed_TInterface_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object).serviceKey}

The service key the family was composed under\.

#### Returns
[Abblix\.DependencyInjection\.IComposition&lt;](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.IComposition_TInterface_ 'Abblix\.DependencyInjection\.IComposition\<TInterface\>')[TInterface](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.DecomposeKeyed_TInterface_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object).TInterface 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.DecomposeKeyed\<TInterface\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, object\)\.TInterface')[&gt;](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.IComposition_TInterface_ 'Abblix\.DependencyInjection\.IComposition\<TInterface\>')  
A live cursor over the family's members, in execution order\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
The family is composed under this key but what a composition
            leaves behind is no longer intact \- either the mark over its members or the composite that heads them has
            been removed from the collection\. No sequence of calls on this API produces that\.

### Remarks
The mechanics mirror [Decompose&lt;TInterface&gt;\(this IServiceCollection\)](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.Decompose_TInterface_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection) 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.Decompose\<TInterface\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)'), except the family's key carries the service
key too, so pipelines of the same interface under different keys stay isolated\.
[IComposition&lt;TInterface&gt;](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.IComposition_TInterface_ 'Abblix\.DependencyInjection\.IComposition\<TInterface\>') adds the same position\-aware sugar
\(`AddAfter`, `Remove`, \.\.\.\)\.

## ServiceCollectionExtensions\.Decorate\<TInterface,TDecorator\>\(this IServiceCollection, Dependency\[\]\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.Decorate_TInterface,TDecorator_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[])}

Decorates a registered service with a decorator implementation\.

```csharp
public static Microsoft.Extensions.DependencyInjection.IServiceCollection Decorate<TInterface,TDecorator>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, params Abblix.DependencyInjection.Dependency[] dependencies)
    where TInterface : class
    where TDecorator : class, TInterface;
```
#### Type parameters

###### `TInterface` {#Abblix.DependencyInjection.ServiceCollectionExtensions.Decorate_TInterface,TDecorator_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).TInterface}

The service type to be decorated\.

###### `TDecorator` {#Abblix.DependencyInjection.ServiceCollectionExtensions.Decorate_TInterface,TDecorator_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).TDecorator}

The decorator implementation type\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.Decorate_TInterface,TDecorator_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).services}

The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') to add the service to\.

###### `dependencies` [Dependency](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.Dependency 'Abblix\.DependencyInjection\.Dependency')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') {#Abblix.DependencyInjection.ServiceCollectionExtensions.Decorate_TInterface,TDecorator_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]).dependencies}

The dependencies required by the decorator\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')  
The updated [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')\.

### Remarks
The decorator pattern allows you to add behavior to existing service implementations without modifying their code\.
The decorator wraps the original service and preserves its lifetime registration\.
The decorator must implement the same interface as the service being decorated\.

## ServiceCollectionExtensions\.DecorateKeyed\<TInterface,TDecorator\>\(this IServiceCollection, object, Dependency\[\]\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.DecorateKeyed_TInterface,TDecorator_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,Abblix.DependencyInjection.Dependency[])}

Decorates a registered keyed service with a decorator implementation\.
If no keyed service is found, falls back to decorating the non\-keyed service
and registers the result as a keyed service\.

```csharp
public static Microsoft.Extensions.DependencyInjection.IServiceCollection DecorateKeyed<TInterface,TDecorator>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, object? serviceKey, params Abblix.DependencyInjection.Dependency[] dependencies)
    where TInterface : class
    where TDecorator : class, TInterface;
```
#### Type parameters

###### `TInterface` {#Abblix.DependencyInjection.ServiceCollectionExtensions.DecorateKeyed_TInterface,TDecorator_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,Abblix.DependencyInjection.Dependency[]).TInterface}

The service type to be decorated\.

###### `TDecorator` {#Abblix.DependencyInjection.ServiceCollectionExtensions.DecorateKeyed_TInterface,TDecorator_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,Abblix.DependencyInjection.Dependency[]).TDecorator}

The decorator implementation type\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.DecorateKeyed_TInterface,TDecorator_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,Abblix.DependencyInjection.Dependency[]).services}

The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') to add the service to\.

###### `serviceKey` [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') {#Abblix.DependencyInjection.ServiceCollectionExtensions.DecorateKeyed_TInterface,TDecorator_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,Abblix.DependencyInjection.Dependency[]).serviceKey}

The service key for the decorated service registration\.

###### `dependencies` [Dependency](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.Dependency 'Abblix\.DependencyInjection\.Dependency')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') {#Abblix.DependencyInjection.ServiceCollectionExtensions.DecorateKeyed_TInterface,TDecorator_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,Abblix.DependencyInjection.Dependency[]).dependencies}

The dependencies required by the decorator\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')  
The updated [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')\.

### Remarks
This method allows decoration of keyed services registered using the keyed service APIs\.
If the keyed service is not found, it falls back to decorating the non\-keyed service
and registers the decorator as a keyed service\. This is useful when you want to create
a keyed variant of an existing non\-keyed service with additional behavior\.
The decorator will wrap the existing implementation while preserving the service lifetime\.

## ServiceCollectionExtensions\.Find\<T\>\(this IServiceCollection\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.Find_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection)}

Finds the registered service descriptor for type [T](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.Find_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).T 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.Find\<T\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)\.T'), or returns `null` if
none exists\.

```csharp
public static Microsoft.Extensions.DependencyInjection.ServiceDescriptor? Find<T>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);
```
#### Type parameters

###### `T` {#Abblix.DependencyInjection.ServiceCollectionExtensions.Find_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).T}

The service type to locate\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.Find_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).services}

The service collection to search\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicedescriptor 'Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor')  
The matching [Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicedescriptor 'Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor'), or `null` if not found\.

## ServiceCollectionExtensions\.FindAll\<T\>\(this IServiceCollection\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.FindAll_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection)}

Finds all registered service descriptors for type [T](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.FindAll_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).T 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.FindAll\<T\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)\.T')\.

```csharp
public static System.Collections.Generic.IEnumerable<Microsoft.Extensions.DependencyInjection.ServiceDescriptor> FindAll<T>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);
```
#### Type parameters

###### `T` {#Abblix.DependencyInjection.ServiceCollectionExtensions.FindAll_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).T}

The service type to locate\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.FindAll_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).services}

The service collection to search\.

#### Returns
[System\.Collections\.Generic\.IEnumerable&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')[Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicedescriptor 'Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')  
An [System\.Collections\.Generic\.IEnumerable&lt;&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1') of matching [Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicedescriptor 'Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor') instances\.

## ServiceCollectionExtensions\.FindRequired\<T\>\(this IServiceCollection\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.FindRequired_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection)}

Finds the first registered service descriptor for type [T](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.FindRequired_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).T 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.FindRequired\<T\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)\.T')\.
Throws if no descriptor is found\.

```csharp
public static Microsoft.Extensions.DependencyInjection.ServiceDescriptor FindRequired<T>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);
```
#### Type parameters

###### `T` {#Abblix.DependencyInjection.ServiceCollectionExtensions.FindRequired_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).T}

The service type to locate\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.FindRequired_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).services}

The service collection to search\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicedescriptor 'Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor')  
The matching [Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicedescriptor 'Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor')\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
Thrown if no descriptor is found for the specified type\.

## ServiceCollectionExtensions\.RemoveAll\<T\>\(this IServiceCollection\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.RemoveAll_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection)}

Removes all registrations of type [T](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.RemoveAll_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).T 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.RemoveAll\<T\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)\.T') from the service collection\.

```csharp
public static Microsoft.Extensions.DependencyInjection.ServiceDescriptor[] RemoveAll<T>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);
```
#### Type parameters

###### `T` {#Abblix.DependencyInjection.ServiceCollectionExtensions.RemoveAll_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).T}

The service type to remove\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.RemoveAll_T_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).services}

The service collection to operate on\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicedescriptor 'Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array')  
`true` if any descriptors were removed; otherwise, `false`\.

### Remarks
Can be used to clean up pre\-registered services before adding custom implementations\.

## ServiceCollectionExtensions\.ResolveImplementationType\(this ServiceDescriptor\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.ResolveImplementationType(thisMicrosoft.Extensions.DependencyInjection.ServiceDescriptor)}

Stand\-in for the internal `ServiceDescriptor.GetImplementationType()`: returns the
implementation type whether the descriptor was registered with an explicit
implementation type, an implementation instance, or a typed factory
`Func<IServiceProvider, TImpl>` \(\.NET 10 generic AddSingleton uses the last shape,
so the property alone returns null for those registrations\)\. Supports both plain and keyed
descriptors \- for keyed ones the type is derived from the `Keyed*` counterparts, including
the keyed factory shape `Func<IServiceProvider, object?, TImpl>` produced when
[Compose&lt;TInterface,TComposite&gt;\(this IServiceCollection, Dependency\[\]\)](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.Compose_TInterface,TComposite_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,Abblix.DependencyInjection.Dependency[]) 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.Compose\<TInterface,TComposite\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, Abblix\.DependencyInjection\.Dependency\[\]\)') moves a family
member into its keyed registration\.

```csharp
public static System.Type? ResolveImplementationType(this Microsoft.Extensions.DependencyInjection.ServiceDescriptor descriptor);
```
#### Parameters

###### `descriptor` [Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicedescriptor 'Microsoft\.Extensions\.DependencyInjection\.ServiceDescriptor') {#Abblix.DependencyInjection.ServiceCollectionExtensions.ResolveImplementationType(thisMicrosoft.Extensions.DependencyInjection.ServiceDescriptor).descriptor}

The descriptor whose implementation type to derive\.

#### Returns
[System\.Type](https://learn.microsoft.com/en-us/dotnet/api/system.type 'System\.Type')  
The implementation type, or null when it cannot be derived \(untyped factory\)\.

## ServiceCollectionExtensions\.TryAddAlias\<TService,TImplementation\>\(this IServiceCollection\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection)}

Adds [TService](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TService 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.TryAddAlias\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)\.TService') as a SHARED\-instance alias for the existing
[TImplementation](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TImplementation 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.TryAddAlias\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)\.TImplementation') registration \- unless [TService](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TService 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.TryAddAlias\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)\.TService')
is already registered\. Sister of [AddAlias&lt;TService,TImplementation&gt;\(this IServiceCollection\)](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.AddAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection) 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.AddAlias\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)') with
`TryAdd` semantics on the alias service type: a host pre\-registration of the aliased
contract wins, which keeps the library\-wide "host pre\-registration wins" convention on
singular seams whose library default is routed through an alias\. Use plain
[AddAlias&lt;TService,TImplementation&gt;\(this IServiceCollection\)](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.AddAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection) 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.AddAlias\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)') only where the alias must be added
unconditionally \(e\.g\. composition machinery that appends to an enumerable set\)\.

```csharp
public static Microsoft.Extensions.DependencyInjection.IServiceCollection TryAddAlias<TService,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services)
    where TService : class
    where TImplementation : class, TService;
```
#### Type parameters

###### `TService` {#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TService}

The service type to register the alias under\.

###### `TImplementation` {#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TImplementation}

The implementation type already registered as a
            concrete \(or as another service\) in the service collection\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).services}

The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') to add to\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')  
The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') so additional calls can be chained\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
Thrown when no registration is found for [TImplementation](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TImplementation 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.TryAddAlias\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)\.TImplementation')\.

## ServiceCollectionExtensions\.TryAddEnumerableAlias\<TService,TImplementation\>\(this IServiceCollection\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddEnumerableAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection)}

Adds [TService](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddEnumerableAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TService 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.TryAddEnumerableAlias\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)\.TService') to an enumerable strategy set as a SHARED\-instance
alias for the existing [TImplementation](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddEnumerableAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TImplementation 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.TryAddEnumerableAlias\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)\.TImplementation') registration\. Sister of
[AddAlias&lt;TService,TImplementation&gt;\(this IServiceCollection\)](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.AddAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection) 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.AddAlias\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)'): same semantic of "route this service
to that already\-registered impl", but adds via `TryAddEnumerable` \(so repeated
calls dedupe on `(ServiceType, ImplementationType)`\) and always uses a typed
factory delegate that resolves through the source registration \- guaranteeing the
alias and the source share one instance\.

```csharp
public static Microsoft.Extensions.DependencyInjection.IServiceCollection TryAddEnumerableAlias<TService,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services)
    where TService : class
    where TImplementation : class, TService;
```
#### Type parameters

###### `TService` {#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddEnumerableAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TService}

The enumerable service type to register the alias under\.

###### `TImplementation` {#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddEnumerableAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TImplementation}

The implementation type already registered as a
            concrete \(or as another [TService](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddEnumerableAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TService 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.TryAddEnumerableAlias\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)\.TService')\) in the service collection\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddEnumerableAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).services}

The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') to add to\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')  
The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') so additional calls can be chained\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
No registration was found for
            [TImplementation](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddEnumerableAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection).TImplementation 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.TryAddEnumerableAlias\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)\.TImplementation')\.

## ServiceCollectionExtensions\.TryAddKeyedAlias\<TService,TSource\>\(this IServiceCollection, object, object\) Method {#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object)}

Creates a keyed alias registration for [TService](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object).TService 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.TryAddKeyedAlias\<TService,TSource\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, object, object\)\.TService') under
[serviceKey](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object).serviceKey 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.TryAddKeyedAlias\<TService,TSource\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, object, object\)\.serviceKey') \- unless that \(service type, key\) pair is already
registered\. Sister of [AddKeyedAlias&lt;TService,TSource&gt;\(this IServiceCollection, object, object\)](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.AddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object) 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.AddKeyedAlias\<TService,TSource\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, object, object\)') with `TryAdd`
semantics on the alias identity: a pre\-existing registration under the same key wins,
mirroring [TryAddAlias&lt;TService,TImplementation&gt;\(this IServiceCollection\)](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddAlias_TService,TImplementation_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection) 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.TryAddAlias\<TService,TImplementation\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection\)') for keyed seams and
keeping the library\-wide "host pre\-registration wins" convention\.

```csharp
public static Microsoft.Extensions.DependencyInjection.IServiceCollection TryAddKeyedAlias<TService,TSource>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, object? serviceKey, object? sourceKey=null)
    where TService : class
    where TSource : class;
```
#### Type parameters

###### `TService` {#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object).TService}

The service type for the alias registration\.

###### `TSource` {#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object).TSource}

The source service type that is already registered\.
#### Parameters

###### `services` [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') {#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object).services}

The [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection') to add the service to\.

###### `serviceKey` [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') {#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object).serviceKey}

The service key to associate with the alias\.

###### `sourceKey` [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') {#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object).sourceKey}

The service key of the source registration\. Use null for non\-keyed source\.

#### Returns
[Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')  
The updated [Microsoft\.Extensions\.DependencyInjection\.IServiceCollection](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection 'Microsoft\.Extensions\.DependencyInjection\.IServiceCollection')\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
Thrown when no registration is found for [TSource](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object).TSource 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.TryAddKeyedAlias\<TService,TSource\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, object, object\)\.TSource') with the specified [sourceKey](https://www.abblix.com/en/docs/api/abblix-dependencyinjection/Abblix.DependencyInjection.ServiceCollectionExtensions#Abblix.DependencyInjection.ServiceCollectionExtensions.TryAddKeyedAlias_TService,TSource_(thisMicrosoft.Extensions.DependencyInjection.IServiceCollection,object,object).sourceKey 'Abblix\.DependencyInjection\.ServiceCollectionExtensions\.TryAddKeyedAlias\<TService,TSource\>\(this Microsoft\.Extensions\.DependencyInjection\.IServiceCollection, object, object\)\.sourceKey')\.
