Class ServiceCollectionExtensions
- Namespace
- Savvyio.Extensions.DependencyInjection
- Assembly
- Savvyio.Extensions.DependencyInjection.dll
Extension methods for the IServiceCollection interface.
public static class ServiceCollectionExtensions
- Inheritance
-
ServiceCollectionExtensions
Methods
AddConfiguredOptions<TOptions>(IServiceCollection, Action<TOptions>)
Registers the specified setup as a triple-configuration for both compatibility with (and outside the confines of) Microsoft Dependency Injection e.g., IOptions<TOptions>, Action<TOptions> and TOptions.
public static IServiceCollection AddConfiguredOptions<TOptions>(this IServiceCollection services, Action<TOptions> setup) where TOptions : class, IParameterObject, new()
Parameters
servicesIServiceCollectionThe IServiceCollection to add the services to.
setupAction<TOptions>The
TOptionswhich need to be configured by thesetupdelegate.
Returns
- IServiceCollection
A reference to
servicesso that additional calls can be chained.
Type Parameters
TOptionsThe options type to be configured.
Exceptions
- ArgumentNullException
servicescannot be null -or-setupcannot be null.- ArgumentException
setupare not in a valid state.
AddDataSource<TService>(IServiceCollection, Action<ServiceOptions>)
Adds an implementation of IDataSource to the specified IServiceCollection.
public static IServiceCollection AddDataSource<TService>(this IServiceCollection services, Action<ServiceOptions> setup = null) where TService : class, IDataSource
Parameters
servicesIServiceCollectionThe IServiceCollection to add the service to.
setupAction<ServiceOptions>The ServiceOptions which may be configured.
Returns
- IServiceCollection
A reference to
servicesso that additional calls can be chained.
Type Parameters
TServiceThe type of the IDataSource to add.
Remarks
If the underlying type of TService implements IDependencyInjectionMarker<TMarker> interface then this is automatically handled. Also, the implementation will be type forwarded accordingly.
Exceptions
- ArgumentNullException
servicescannot be null.
- See Also
-
IDependencyInjectionMarker<TMarker>IDataSource<TMarker>
AddHandlerServicesDescriptor(IServiceCollection)
Adds the HandlerServicesDescriptor to the specified IServiceCollection if it was allowed included from AddSavvyIO(IServiceCollection, Action<SavvyioDependencyInjectionOptions>).
public static IServiceCollection AddHandlerServicesDescriptor(this IServiceCollection services)
Parameters
servicesIServiceCollectionThe IServiceCollection to add the service to.
Returns
- IServiceCollection
A reference to
servicesso that additional calls can be chained.
Exceptions
- ArgumentNullException
servicescannot be null.
AddMarshaller<TService>(IServiceCollection, Action<ServiceOptions>)
Adds an implementation of IMarshaller to the specified IServiceCollection.
public static IServiceCollection AddMarshaller<TService>(this IServiceCollection services, Action<ServiceOptions> setup = null) where TService : class, IMarshaller
Parameters
servicesIServiceCollectionThe IServiceCollection to add the service to.
setupAction<ServiceOptions>The ServiceOptions which may be configured.
Returns
- IServiceCollection
A reference to
servicesso that additional calls can be chained.
Type Parameters
TServiceThe type of the IMarshaller to add.
Exceptions
- ArgumentNullException
servicescannot be null.
AddMarshaller<TService>(IServiceCollection, Func<IServiceProvider, TService>, Action<ServiceOptions>)
Adds an implementation of IMarshaller to the specified IServiceCollection.
public static IServiceCollection AddMarshaller<TService>(this IServiceCollection services, Func<IServiceProvider, TService> implementationFactory, Action<ServiceOptions> setup = null) where TService : class, IMarshaller
Parameters
servicesIServiceCollectionThe IServiceCollection to add the service to.
implementationFactoryFunc<IServiceProvider, TService>The function delegate that creates the service.
setupAction<ServiceOptions>The ServiceOptions which may be configured.
Returns
- IServiceCollection
A reference to
servicesso that additional calls can be chained.
Type Parameters
TServiceThe type of the IMarshaller to add.
Exceptions
- ArgumentNullException
servicescannot be null -or-implementationFactorycannot be null.
AddSavvyIO(IServiceCollection, Action<SavvyioDependencyInjectionOptions>)
Adds Savvy I/O related dispatcher- and handler- types to the specified IServiceCollection.
public static IServiceCollection AddSavvyIO(this IServiceCollection services, Action<SavvyioDependencyInjectionOptions> setup = null)
Parameters
servicesIServiceCollectionThe IServiceCollection to extend.
setupAction<SavvyioDependencyInjectionOptions>The SavvyioDependencyInjectionOptions which may be configured.
Returns
- IServiceCollection
A reference to
servicesso that additional calls can be chained.
Exceptions
- ArgumentNullException
servicescannot be null.
AddServiceLocator(IServiceCollection, Action<ServiceLocatorOptions>)
Adds Savvy I/O service locator used to resolve necessary dependencies.
public static IServiceCollection AddServiceLocator(this IServiceCollection services, Action<ServiceLocatorOptions> setup = null)
Parameters
servicesIServiceCollectionThe IServiceCollection to extend.
setupAction<ServiceLocatorOptions>The ServiceLocatorOptions which may be configured.
Returns
- IServiceCollection
A reference to
servicesso that additional calls can be chained.
Exceptions
- ArgumentNullException
servicescannot be null.