Table of Contents

Add Method

Definition

Namespace
Cuemon.Extensions.DependencyInjection
Assemblies
Cuemon.Extensions.DependencyInjection.dll
Source
src/Cuemon.Extensions.DependencyInjection/ServiceCollectionExtensions.cs

Add<TService, TImplementation>(IServiceCollection, ServiceLifetime)

Adds the specified TService with the TImplementation and lifetime to the services.

public static IServiceCollection Add<TService, TImplementation>(this IServiceCollection services, ServiceLifetime lifetime) where TService : class where TImplementation : class, TService

Parameters

services IServiceCollection

The IServiceCollection to add the service to.

lifetime ServiceLifetime

The lifetime of the service.

Returns

IServiceCollection

A reference to services so that additional configuration calls can be chained.

Type Parameters

TService

The type of the service to add.

TImplementation

The type of the implementation to use.

Add<TService, TImplementation, TOptions>(IServiceCollection, ServiceLifetime, Action<TOptions>)

Adds the specified TService with the TImplementation and lifetime to the services.

public static IServiceCollection Add<TService, TImplementation, TOptions>(this IServiceCollection services, ServiceLifetime lifetime, Action<TOptions> setup) where TService : class where TImplementation : class, TService where TOptions : class, new()

Parameters

services IServiceCollection

The IServiceCollection to add the service to.

lifetime ServiceLifetime

The lifetime of the service.

setup Action<TOptions>

The TOptions which need to be configured.

Returns

IServiceCollection

A reference to services so that additional configuration calls can be chained.

Type Parameters

TService

The type of the service to add.

TImplementation

The type of the implementation to use.

TOptions

The type of the configured options.

Add(IServiceCollection, Type, Type, ServiceLifetime)

Adds the specified service with the implementation and lifetime to the services.

public static IServiceCollection Add(this IServiceCollection services, Type service, Type implementation, ServiceLifetime lifetime)

Parameters

services IServiceCollection

The IServiceCollection to add the service to.

service Type

The type of the service to register.

implementation Type

The implementation type of the service.

lifetime ServiceLifetime

The lifetime of the service.

Returns

IServiceCollection

A reference to services so that additional configuration calls can be chained.

Add<TOptions>(IServiceCollection, Type, Type, ServiceLifetime, Action<TOptions>)

Adds the specified service with the implementation and lifetime to the services.

public static IServiceCollection Add<TOptions>(this IServiceCollection services, Type service, Type implementation, ServiceLifetime lifetime, Action<TOptions> setup) where TOptions : class, new()

Parameters

services IServiceCollection

The IServiceCollection to add the service to.

service Type

The type of the service to register.

implementation Type

The implementation type of the service.

lifetime ServiceLifetime

The lifetime of the service.

setup Action<TOptions>

The TOptions which need to be configured.

Returns

IServiceCollection

A reference to services so that additional configuration calls can be chained.

Type Parameters

TOptions

The type of the configured options.

Add<TService, TImplementation>(IServiceCollection, Func<IServiceProvider, TImplementation>, ServiceLifetime)

Adds the specified TService with the TImplementation and lifetime to the services.

public static IServiceCollection Add<TService, TImplementation>(this IServiceCollection services, Func<IServiceProvider, TImplementation> implementationFactory, ServiceLifetime lifetime) where TService : class where TImplementation : class, TService

Parameters

services IServiceCollection

The IServiceCollection to add the service to.

implementationFactory Func<IServiceProvider, TImplementation>

The function delegate that creates the service.

lifetime ServiceLifetime

The lifetime of the service.

Returns

IServiceCollection

A reference to services so that additional configuration calls can be chained.

Type Parameters

TService

The type of the service to add.

TImplementation

The type of the implementation to use.

Add<TService, TImplementation, TOptions>(IServiceCollection, Func<IServiceProvider, TImplementation>, ServiceLifetime, Action<TOptions>)

Adds the specified TService with the TImplementation and lifetime to the services.

public static IServiceCollection Add<TService, TImplementation, TOptions>(this IServiceCollection services, Func<IServiceProvider, TImplementation> implementationFactory, ServiceLifetime lifetime, Action<TOptions> setup) where TService : class where TImplementation : class, TService where TOptions : class, new()

Parameters

services IServiceCollection

The IServiceCollection to add the service to.

implementationFactory Func<IServiceProvider, TImplementation>

The function delegate that creates the service.

lifetime ServiceLifetime

The lifetime of the service.

setup Action<TOptions>

The TOptions which need to be configured.

Returns

IServiceCollection

A reference to services so that additional configuration calls can be chained.

Type Parameters

TService

The type of the service to add.

TImplementation

The type of the implementation to use.

TOptions

The type of the configured options.

Add(IServiceCollection, Type, Func<IServiceProvider, object>, ServiceLifetime)

Adds the specified service with the implementationFactory and lifetime to the services.

public static IServiceCollection Add(this IServiceCollection services, Type service, Func<IServiceProvider, object> implementationFactory, ServiceLifetime lifetime)

Parameters

services IServiceCollection

The IServiceCollection to add the service to.

service Type

The type of the service to register.

implementationFactory Func<IServiceProvider, object>

The function delegate that creates the service.

lifetime ServiceLifetime

The lifetime of the service.

Returns

IServiceCollection

A reference to services so that additional configuration calls can be chained.

Add<TOptions>(IServiceCollection, Type, Func<IServiceProvider, object>, ServiceLifetime, Action<TOptions>)

Adds the specified service with the implementationFactory and lifetime to the services.

public static IServiceCollection Add<TOptions>(this IServiceCollection services, Type service, Func<IServiceProvider, object> implementationFactory, ServiceLifetime lifetime, Action<TOptions> setup) where TOptions : class, new()

Parameters

services IServiceCollection

The IServiceCollection to add the service to.

service Type

The type of the service to register.

implementationFactory Func<IServiceProvider, object>

The function delegate that creates the service.

lifetime ServiceLifetime

The lifetime of the service.

setup Action<TOptions>

The TOptions which need to be configured.

Returns

IServiceCollection

A reference to services so that additional configuration calls can be chained.

Type Parameters

TOptions

The type of the configured options.

Add<TService>(IServiceCollection, Action<TypeForwardServiceOptions>)

Adds the specified TService with the configured setup to the services.

public static IServiceCollection Add<TService>(this IServiceCollection services, Action<TypeForwardServiceOptions> setup = null) where TService : class

Parameters

services IServiceCollection

The IServiceCollection to add the service to.

setup Action<TypeForwardServiceOptions>

The TypeForwardServiceOptions which may be configured.

Returns

IServiceCollection

A reference to services so that additional configuration calls can be chained.

Type Parameters

TService

The type of the service to add.

Remarks

If the underlying type of TService implements IDependencyInjectionMarker<TMarker> interface then this is automatically handled.

Add<TService, TImplementation>(IServiceCollection, Action<TypeForwardServiceOptions>)

Adds the specified TService with the TImplementation and configured setup to the services.

public static IServiceCollection Add<TService, TImplementation>(this IServiceCollection services, Action<TypeForwardServiceOptions> setup = null) where TService : class where TImplementation : class, TService

Parameters

services IServiceCollection

The IServiceCollection to add the service to.

setup Action<TypeForwardServiceOptions>

The TypeForwardServiceOptions which may be configured.

Returns

IServiceCollection

A reference to services so that additional configuration calls can be chained.

Type Parameters

TService

The type of the service to add.

TImplementation

The type of the implementation to use.

Add(IServiceCollection, Type, Type, Action<TypeForwardServiceOptions>)

Adds the specified service with the implementation and configured setup to the services.

public static IServiceCollection Add(this IServiceCollection services, Type service, Type implementation, Action<TypeForwardServiceOptions> setup = null)

Parameters

services IServiceCollection

The IServiceCollection to add the service to.

service Type

The type of the service to register.

implementation Type

The implementation type of the service.

setup Action<TypeForwardServiceOptions>

The TypeForwardServiceOptions which may be configured.

Returns

IServiceCollection

A reference to services so that additional configuration calls can be chained.

Add<TService>(IServiceCollection, Func<IServiceProvider, TService>, Action<TypeForwardServiceOptions>)

Adds the specified TService with the configured setup to the services.

public static IServiceCollection Add<TService>(this IServiceCollection services, Func<IServiceProvider, TService> implementationFactory, Action<TypeForwardServiceOptions> setup = null) where TService : class

Parameters

services IServiceCollection

The IServiceCollection to add the service to.

implementationFactory Func<IServiceProvider, TService>

The function delegate that creates the service.

setup Action<TypeForwardServiceOptions>

The TypeForwardServiceOptions which may be configured.

Returns

IServiceCollection

A reference to services so that additional configuration calls can be chained.

Type Parameters

TService

The type of the service to add.

Add<TService, TImplementation>(IServiceCollection, Func<IServiceProvider, TImplementation>, Action<TypeForwardServiceOptions>)

Adds the specified TService with the TImplementation and configured setup to the services.

public static IServiceCollection Add<TService, TImplementation>(this IServiceCollection services, Func<IServiceProvider, TImplementation> implementationFactory, Action<TypeForwardServiceOptions> setup = null) where TService : class where TImplementation : class, TService

Parameters

services IServiceCollection

The IServiceCollection to add the service to.

implementationFactory Func<IServiceProvider, TImplementation>

The function delegate that creates the service.

setup Action<TypeForwardServiceOptions>

The TypeForwardServiceOptions which may be configured.

Returns

IServiceCollection

A reference to services so that additional configuration calls can be chained.

Type Parameters

TService

The type of the service to add.

TImplementation

The type of the implementation to use.

Add(IServiceCollection, Type, Func<IServiceProvider, object>, Action<TypeForwardServiceOptions>)

Adds the specified service with the implementationFactory and configured setup to the services.

public static IServiceCollection Add(this IServiceCollection services, Type service, Func<IServiceProvider, object> implementationFactory, Action<TypeForwardServiceOptions> setup = null)

Parameters

services IServiceCollection

The IServiceCollection to add the service to.

service Type

The type of the service to register.

implementationFactory Func<IServiceProvider, object>

The function delegate that creates the service.

setup Action<TypeForwardServiceOptions>

The TypeForwardServiceOptions which may be configured.

Returns

IServiceCollection

A reference to services so that additional configuration calls can be chained.