Class DecoratorServiceCollectionExtensions
Extension methods for Microsoft.Extensions.DependencyInjection.IServiceCollection.
Inheritance
Inherited Members
Namespace: Microsoft.Extensions.DependencyInjection
Assembly: CSF.DecoratorBuilder.Extensions.DependencyInjection.dll
Syntax
public static class DecoratorServiceCollectionExtensions
Methods
| Improve this Doc View SourceAddDecoratorBuilder(IServiceCollection)
Adds services to the service collection so that decorator-builder services are available from dependency injection.
Declaration
public static void AddDecoratorBuilder(this IServiceCollection services)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | A service collection. |
Remarks
This method adds implementations of the following interfaces to the service collection:
This method must be used in order to activate the decorator builder functionality within dependency injection for your application.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If |
AddScopedDecorator(IServiceCollection, Type, Func<ICreatesDecorator, ICustomizesDecorator>, ITypedResolvable[])
Adds logic for a service, resolved using the decorator pattern, to the service collection. This method adds the service with a scoped lifetime.
Declaration
public static void AddScopedDecorator(this IServiceCollection services, Type serviceType, Func<ICreatesDecorator, ICustomizesDecorator> customizationFunc, params ITypedResolvable[] globalParams)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | A service collection. |
System.Type | serviceType | The service type. |
System.Func<ICreatesDecorator, ICustomizesDecorator> | customizationFunc | A function/lambda which specifies how the service is to be built, via the decorator pattern. |
ITypedResolvable[] | globalParams | An optional collection of parameters which will be globally applied to every resolution operation. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If |
AddScopedDecorator<TService>(IServiceCollection, Func<ICreatesDecorator<TService>, ICustomizesDecorator<TService>>, ITypedResolvable[])
Adds logic for a service, resolved using the decorator pattern, to the service collection. This method adds the service with a scoped lifetime.
Declaration
public static void AddScopedDecorator<TService>(this IServiceCollection services, Func<ICreatesDecorator<TService>, ICustomizesDecorator<TService>> customizationFunc, params ITypedResolvable[] globalParams)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | A service collection. |
System.Func<ICreatesDecorator<TService>, ICustomizesDecorator<TService>> | customizationFunc | A function/lambda which specifies how the service is to be built, via the decorator pattern. |
ITypedResolvable[] | globalParams | An optional collection of parameters which will be globally applied to every resolution operation. |
Type Parameters
Name | Description |
---|---|
TService | The service type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If |
AddSingletonDecorator(IServiceCollection, Type, Func<ICreatesDecorator, ICustomizesDecorator>, ITypedResolvable[])
Adds logic for a service, resolved using the decorator pattern, to the service collection. This method adds the service with a singleton lifetime.
Declaration
public static void AddSingletonDecorator(this IServiceCollection services, Type serviceType, Func<ICreatesDecorator, ICustomizesDecorator> customizationFunc, params ITypedResolvable[] globalParams)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | A service collection. |
System.Type | serviceType | The service type. |
System.Func<ICreatesDecorator, ICustomizesDecorator> | customizationFunc | A function/lambda which specifies how the service is to be built, via the decorator pattern. |
ITypedResolvable[] | globalParams | An optional collection of parameters which will be globally applied to every resolution operation. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If |
AddSingletonDecorator<TService>(IServiceCollection, Func<ICreatesDecorator<TService>, ICustomizesDecorator<TService>>, ITypedResolvable[])
Adds logic for a service, resolved using the decorator pattern, to the service collection. This method adds the service with a singleton lifetime.
Declaration
public static void AddSingletonDecorator<TService>(this IServiceCollection services, Func<ICreatesDecorator<TService>, ICustomizesDecorator<TService>> customizationFunc, params ITypedResolvable[] globalParams)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | A service collection. |
System.Func<ICreatesDecorator<TService>, ICustomizesDecorator<TService>> | customizationFunc | A function/lambda which specifies how the service is to be built, via the decorator pattern. |
ITypedResolvable[] | globalParams | An optional collection of parameters which will be globally applied to every resolution operation. |
Type Parameters
Name | Description |
---|---|
TService | The service type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If |
AddTransientDecorator(IServiceCollection, Type, Func<ICreatesDecorator, ICustomizesDecorator>, ITypedResolvable[])
Adds logic for a service, resolved using the decorator pattern, to the service collection. This method adds the service with a transient lifetime.
Declaration
public static void AddTransientDecorator(this IServiceCollection services, Type serviceType, Func<ICreatesDecorator, ICustomizesDecorator> customizationFunc, params ITypedResolvable[] globalParams)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | A service collection. |
System.Type | serviceType | The service type. |
System.Func<ICreatesDecorator, ICustomizesDecorator> | customizationFunc | A function/lambda which specifies how the service is to be built, via the decorator pattern. |
ITypedResolvable[] | globalParams | An optional collection of parameters which will be globally applied to every resolution operation. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If |
AddTransientDecorator<TService>(IServiceCollection, Func<ICreatesDecorator<TService>, ICustomizesDecorator<TService>>, ITypedResolvable[])
Adds logic for a service, resolved using the decorator pattern, to the service collection. This method adds the service with a transient lifetime.
Declaration
public static void AddTransientDecorator<TService>(this IServiceCollection services, Func<ICreatesDecorator<TService>, ICustomizesDecorator<TService>> customizationFunc, params ITypedResolvable[] globalParams)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | A service collection. |
System.Func<ICreatesDecorator<TService>, ICustomizesDecorator<TService>> | customizationFunc | A function/lambda which specifies how the service is to be built, via the decorator pattern. |
ITypedResolvable[] | globalParams | An optional collection of parameters which will be globally applied to every resolution operation. |
Type Parameters
Name | Description |
---|---|
TService | The service type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If |