Show / Hide Table of Contents

Class DecoratorServiceCollectionExtensions

Extension methods for Microsoft.Extensions.DependencyInjection.IServiceCollection.

Inheritance
System.Object
DecoratorServiceCollectionExtensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Microsoft.Extensions.DependencyInjection
Assembly: CSF.DecoratorBuilder.Extensions.DependencyInjection.dll
Syntax
public static class DecoratorServiceCollectionExtensions

Methods

| Improve this Doc View Source

AddDecoratorBuilder(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:

  • IGetsDecoratedService
  • IGetsDecoratedServiceFromResolutionInfo
  • IGetsSingleObjectFromResolutionInfo

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 services is null.

| Improve this Doc View Source

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 services is null.

| Improve this Doc View Source

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 services is null.

| Improve this Doc View Source

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 services is null.

| Improve this Doc View Source

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 services is null.

| Improve this Doc View Source

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 services is null.

| Improve this Doc View Source

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 services is null.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX