Class ServiceCollectionExtensions
- Assembly
- Cuemon.Extensions.DependencyInjection.dll
Extension methods for the IServiceCollection interface.
public static class ServiceCollectionExtensions
- Inheritance
-
ServiceCollectionExtensions
Methods
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
IServiceCollectionThe IServiceCollection to add the service to.
service
TypeThe type of the service to register.
implementationFactory
Func<IServiceProvider, Object>The function delegate that creates the service.
lifetime
ServiceLifetimeThe lifetime of the service.
Returns
- IServiceCollection
A reference to
services
so that additional configuration calls can be chained.
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
IServiceCollectionThe IServiceCollection to add the service to.
service
TypeThe 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.
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
IServiceCollectionThe IServiceCollection to add the service to.
service
TypeThe type of the service to register.
implementation
TypeThe implementation type of the service.
lifetime
ServiceLifetimeThe lifetime of the service.
Returns
- IServiceCollection
A reference to
services
so that additional configuration calls can be chained.
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
IServiceCollectionThe IServiceCollection to add the service to.
service
TypeThe type of the service to register.
implementation
TypeThe 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, 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
IServiceCollectionThe 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>(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
IServiceCollectionThe 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<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
IServiceCollectionThe IServiceCollection to add the service to.
service
TypeThe type of the service to register.
implementationFactory
Func<IServiceProvider, Object>The function delegate that creates the service.
lifetime
ServiceLifetimeThe 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<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
IServiceCollectionThe IServiceCollection to add the service to.
service
TypeThe type of the service to register.
implementation
TypeThe implementation type of the service.
lifetime
ServiceLifetimeThe 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, 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
IServiceCollectionThe IServiceCollection to add the service to.
lifetime
ServiceLifetimeThe 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>(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
IServiceCollectionThe 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<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
IServiceCollectionThe IServiceCollection to add the service to.
implementationFactory
Func<IServiceProvider, TImplementation>The function delegate that creates the service.
lifetime
ServiceLifetimeThe 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>(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
IServiceCollectionThe 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<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
IServiceCollectionThe IServiceCollection to add the service to.
lifetime
ServiceLifetimeThe 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<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
IServiceCollectionThe IServiceCollection to add the service to.
implementationFactory
Func<IServiceProvider, TImplementation>The function delegate that creates the service.
lifetime
ServiceLifetimeThe 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.
PostConfigureAllOf<TOptions>(IServiceCollection, Action<TOptions>)
Registers an action used to post-configure all instances of a specific TOptions
type in the services
collection.
These are run after Configure<TOptions>(IServiceCollection, Action<TOptions>).
public static IServiceCollection PostConfigureAllOf<TOptions>(this IServiceCollection services, Action<TOptions> setup)
where TOptions : class
Parameters
services
IServiceCollectionThe IServiceCollection to extend.
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 options type to be configured.
Remarks
Iterates over all the services in the collection, and if the service is of type IConfigureOptions<TOptions> and its generic type argument matches the specified TOptions
type, it creates a new instance of PostConfigureOptions<TOptions> for that service and adds it to the services
collection.
TryAdd(IServiceCollection, Type, Func<IServiceProvider, Object>, ServiceLifetime)
Adds the specified service
with the implementationFactory
and lifetime
to the services
if the service type has not already been registered.
public static IServiceCollection TryAdd(this IServiceCollection services, Type service, Func<IServiceProvider, object> implementationFactory, ServiceLifetime lifetime)
Parameters
services
IServiceCollectionThe IServiceCollection to add the service to.
service
TypeThe type of the service to register.
implementationFactory
Func<IServiceProvider, Object>The function delegate that creates the service.
lifetime
ServiceLifetimeThe lifetime of the service.
Returns
- IServiceCollection
A reference to
services
so that additional configuration calls can be chained.
TryAdd(IServiceCollection, Type, Func<IServiceProvider, Object>, Action<TypeForwardServiceOptions>)
Adds the specified service
with the implementationFactory
and configured setup
to the services
if the service type has not already been registered.
public static IServiceCollection TryAdd(this IServiceCollection services, Type service, Func<IServiceProvider, object> implementationFactory, Action<TypeForwardServiceOptions> setup = null)
Parameters
services
IServiceCollectionThe IServiceCollection to add the service to.
service
TypeThe 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.
TryAdd(IServiceCollection, Type, Type, ServiceLifetime)
Adds the specified service
with the implementation
and lifetime
to the services
if the service type has not already been registered.
public static IServiceCollection TryAdd(this IServiceCollection services, Type service, Type implementation, ServiceLifetime lifetime)
Parameters
services
IServiceCollectionThe IServiceCollection to add the service to.
service
TypeThe type of the service to register.
implementation
TypeThe implementation type of the service.
lifetime
ServiceLifetimeThe lifetime of the service.
Returns
- IServiceCollection
A reference to
services
so that additional configuration calls can be chained.
TryAdd(IServiceCollection, Type, Type, Action<TypeForwardServiceOptions>)
Adds the specified service
with the implementation
and configured setup
to the services
if the service type has not already been registered.
public static IServiceCollection TryAdd(this IServiceCollection services, Type service, Type implementation, Action<TypeForwardServiceOptions> setup = null)
Parameters
services
IServiceCollectionThe IServiceCollection to add the service to.
service
TypeThe type of the service to register.
implementation
TypeThe 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.
TryAdd<TService>(IServiceCollection, Action<TypeForwardServiceOptions>)
Adds the specified TService
with the configured setup
to the services
if the service type has not already been registered.
public static IServiceCollection TryAdd<TService>(this IServiceCollection services, Action<TypeForwardServiceOptions> setup = null)
where TService : class
Parameters
services
IServiceCollectionThe 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.
TryAdd<TService>(IServiceCollection, Func<IServiceProvider, TService>, Action<TypeForwardServiceOptions>)
Adds the specified TService
with the configured setup
to the services
if the service type has not already been registered.
public static IServiceCollection TryAdd<TService>(this IServiceCollection services, Func<IServiceProvider, TService> implementationFactory, Action<TypeForwardServiceOptions> setup = null)
where TService : class
Parameters
services
IServiceCollectionThe 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.
TryAdd<TOptions>(IServiceCollection, Type, Func<IServiceProvider, Object>, ServiceLifetime, Action<TOptions>)
Adds the specified service
with the implementationFactory
and lifetime
to the services
if the service type has not already been registered.
public static IServiceCollection TryAdd<TOptions>(this IServiceCollection services, Type service, Func<IServiceProvider, object> implementationFactory, ServiceLifetime lifetime, Action<TOptions> setup)
where TOptions : class, new()
Parameters
services
IServiceCollectionThe IServiceCollection to add the service to.
service
TypeThe type of the service to register.
implementationFactory
Func<IServiceProvider, Object>The function delegate that creates the service.
lifetime
ServiceLifetimeThe 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.
TryAdd<TOptions>(IServiceCollection, Type, Type, ServiceLifetime, Action<TOptions>)
Adds the specified service
with the implementation
and lifetime
to the services
if the service type has not already been registered.
public static IServiceCollection TryAdd<TOptions>(this IServiceCollection services, Type service, Type implementation, ServiceLifetime lifetime, Action<TOptions> setup)
where TOptions : class, new()
Parameters
services
IServiceCollectionThe IServiceCollection to add the service to.
service
TypeThe type of the service to register.
implementation
TypeThe implementation type of the service.
lifetime
ServiceLifetimeThe 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.
TryAdd<TService, TImplementation>(IServiceCollection, ServiceLifetime)
Adds the specified TService
with the TImplementation
and lifetime
to the services
if the service type has not already been registered.
public static IServiceCollection TryAdd<TService, TImplementation>(this IServiceCollection services, ServiceLifetime lifetime)
where TService : class where TImplementation : class, TService
Parameters
services
IServiceCollectionThe IServiceCollection to add the service to.
lifetime
ServiceLifetimeThe 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.
TryAdd<TService, TImplementation>(IServiceCollection, Action<TypeForwardServiceOptions>)
Adds the specified TService
with the TImplementation
and configured setup
to the services
if the service type has not already been registered.
public static IServiceCollection TryAdd<TService, TImplementation>(this IServiceCollection services, Action<TypeForwardServiceOptions> setup = null)
where TService : class where TImplementation : class, TService
Parameters
services
IServiceCollectionThe 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.
TryAdd<TService, TImplementation>(IServiceCollection, Func<IServiceProvider, TImplementation>, ServiceLifetime)
Adds the specified TService
with the TImplementation
and lifetime
to the services
if the service type has not already been registered.
public static IServiceCollection TryAdd<TService, TImplementation>(this IServiceCollection services, Func<IServiceProvider, TImplementation> implementationFactory, ServiceLifetime lifetime)
where TService : class where TImplementation : class, TService
Parameters
services
IServiceCollectionThe IServiceCollection to add the service to.
implementationFactory
Func<IServiceProvider, TImplementation>The function delegate that creates the service.
lifetime
ServiceLifetimeThe 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.
TryAdd<TService, TImplementation>(IServiceCollection, Func<IServiceProvider, TImplementation>, Action<TypeForwardServiceOptions>)
Adds the specified TService
with the TImplementation
and configured setup
to the services
if the service type has not already been registered.
public static IServiceCollection TryAdd<TService, TImplementation>(this IServiceCollection services, Func<IServiceProvider, TImplementation> implementationFactory, Action<TypeForwardServiceOptions> setup = null)
where TService : class where TImplementation : class, TService
Parameters
services
IServiceCollectionThe 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.
TryAdd<TService, TImplementation, TOptions>(IServiceCollection, ServiceLifetime, Action<TOptions>)
Adds the specified TService
with the TImplementation
and lifetime
to the services
if the service type has not already been registered.
public static IServiceCollection TryAdd<TService, TImplementation, TOptions>(this IServiceCollection services, ServiceLifetime lifetime, Action<TOptions> setup)
where TService : class where TImplementation : class, TService where TOptions : class, new()
Parameters
services
IServiceCollectionThe IServiceCollection to add the service to.
lifetime
ServiceLifetimeThe 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.
TryAdd<TService, TImplementation, TOptions>(IServiceCollection, Func<IServiceProvider, TImplementation>, ServiceLifetime, Action<TOptions>)
Adds the specified TService
with the TImplementation
and lifetime
to the services
if the service type has not already been registered.
public static IServiceCollection TryAdd<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
IServiceCollectionThe IServiceCollection to add the service to.
implementationFactory
Func<IServiceProvider, TImplementation>The function delegate that creates the service.
lifetime
ServiceLifetimeThe 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.
TryConfigure<TOptions>(IServiceCollection, Action<TOptions>)
Registers the specified setup
used to configure TOptions
to the services
if not already registered.
public static IServiceCollection TryConfigure<TOptions>(this IServiceCollection services, Action<TOptions> setup)
where TOptions : class, new()
Parameters
services
IServiceCollectionThe IServiceCollection to add the
TOptions
to.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 options type to be configured.