Class IServiceCollectionAdvancedExtensions

Defines advanced extensions for the IServiceCollection interface.

Inheritance
System.Object
IServiceCollectionAdvancedExtensions
Namespace: Solti.Utils.DI
Assembly: Solti.Utils.DI.dll
Syntax
public static class IServiceCollectionAdvancedExtensions : Object

Methods

Decorate(IServiceCollection, IEnumerable<(Type, Object)>)

Hooks into the instantiating process to let you decorate the original service. Useful when you want to add additional functionality (e.g. parameter validation).

Declaration
public static IServiceCollection Decorate(this IServiceCollection self, IEnumerable<(Type, object)> interceptors)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Collections.Generic.IEnumerable<System.ValueTuple<System.Type, System.Object>> interceptors

The interceptors to be applied.

Returns
Type Description
IServiceCollection
Remarks

Using this method is the preferred way to apply multiple interceptors against the same service as it will only create one backing proxy.

Exceptions
Type Condition
System.NotSupportedException

When proxying is not allowed (see remarks).

Decorate(IServiceCollection, Type)

Hooks into the instantiating process to let you decorate the original service. Useful when you want to add additional functionality (e.g. parameter validation).

Declaration
public static IServiceCollection Decorate(this IServiceCollection self, Type interceptor)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Type interceptor

The interceptor type.

Returns
Type Description
IServiceCollection
Remarks
Exceptions
Type Condition
System.NotSupportedException

When proxying is not allowed (see remarks).

Decorate(IServiceCollection, Type, Object)

Hooks into the instantiating process to let you decorate the original service. Useful when you want to add additional functionality (e.g. parameter validation).

Declaration
public static IServiceCollection Decorate(this IServiceCollection self, Type interceptor, object explicitArgs)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Type interceptor

The interceptor type.

System.Object explicitArgs

Explicit arguments to be passed.

Returns
Type Description
IServiceCollection
Remarks
Exceptions
Type Condition
System.NotSupportedException

When proxying is not allowed (see remarks).

Decorate(IServiceCollection, Type, Object, IEnumerable<(Type, Object)>)

Hooks into the instantiating process to let you decorate the original service. Useful when you want to add additional functionality (e.g. parameter validation).

Declaration
public static IServiceCollection Decorate(this IServiceCollection self, Type type, object key, IEnumerable<(Type, object)> interceptors)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Type type

The service type.

System.Object key

The (optional) service key (usually a name).

System.Collections.Generic.IEnumerable<System.ValueTuple<System.Type, System.Object>> interceptors

Interceptors to be applied.

Returns
Type Description
IServiceCollection
Remarks

Using this method is the preferred way to apply multiple interceptors against the same service as it will only create one backing proxy.

Exceptions
Type Condition
System.NotSupportedException

When proxying is not allowed (see remarks).

Decorate(IServiceCollection, Type, Object, Type)

Hooks into the instantiating process to let you decorate the original service. Useful when you want to add additional functionality (e.g. parameter validation).

Declaration
public static IServiceCollection Decorate(this IServiceCollection self, Type type, object key, Type interceptor)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Type type

The service type.

System.Object key

The (optional) service key (usually a name).

System.Type interceptor

The interceptor type.

Returns
Type Description
IServiceCollection
Remarks
Exceptions
Type Condition
System.NotSupportedException

When proxying is not allowed (see remarks).

Decorate(IServiceCollection, Type, Object, Type, Object)

Hooks into the instantiating process to let you decorate the original service. Useful when you want to add additional functionality (e.g. parameter validation).

Declaration
public static IServiceCollection Decorate(this IServiceCollection self, Type type, object key, Type interceptor, object explicitArgs)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Type type

The service type.

System.Object key

The (optional) service key (usually a name).

System.Type interceptor

The interceptor type.

System.Object explicitArgs

Explicit arguments to be passed.

Returns
Type Description
IServiceCollection
Remarks
Exceptions
Type Condition
System.NotSupportedException

When proxying is not allowed (see remarks).

Decorate(IServiceCollection, Type, Object, Type[])

Hooks into the instantiating process to let you decorate the original service. Useful when you want to add additional functionality (e.g. parameter validation).

Declaration
public static IServiceCollection Decorate(this IServiceCollection self, Type type, object key, params Type[] interceptors)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Type type

The service type.

System.Object key

The (optional) service key (usually a name).

System.Type[] interceptors

Interceptors to be applied.

Returns
Type Description
IServiceCollection
Remarks

Using this method is the preferred way to apply multiple interceptors against the same service as it will only create one backing proxy.

Exceptions
Type Condition
System.NotSupportedException

When proxying is not allowed (see remarks).

Decorate(IServiceCollection, Type, Object, (Type, Object)[])

Hooks into the instantiating process to let you decorate the original service. Useful when you want to add additional functionality (e.g. parameter validation).

Declaration
public static IServiceCollection Decorate(this IServiceCollection self, Type type, object key, params (Type, object)[] interceptors)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Type type

The service type.

System.Object key

The (optional) service key (usually a name).

System.ValueTuple<System.Type, System.Object>[] interceptors

Interceptors to be applied.

Returns
Type Description
IServiceCollection
Remarks

Using this method is the preferred way to apply multiple interceptors against the same service as it will only create one backing proxy.

Exceptions
Type Condition
System.NotSupportedException

When proxying is not allowed (see remarks).

Decorate(IServiceCollection, Type, Type)

Hooks into the instantiating process to let you decorate the original service. Useful when you want to add additional functionality (e.g. parameter validation).

Declaration
public static IServiceCollection Decorate(this IServiceCollection self, Type type, Type interceptor)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Type type

The service type.

System.Type interceptor

The interceptor type.

Returns
Type Description
IServiceCollection
Remarks
Exceptions
Type Condition
System.NotSupportedException

When proxying is not allowed (see remarks).

Decorate(IServiceCollection, Type, Type, Object)

Hooks into the instantiating process to let you decorate the original service. Useful when you want to add additional functionality (e.g. parameter validation).

Declaration
public static IServiceCollection Decorate(this IServiceCollection self, Type type, Type interceptor, object explicitArgs)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Type type

The service type.

System.Type interceptor

The interceptor type.

System.Object explicitArgs

Explicit arguments to be passed.

Returns
Type Description
IServiceCollection
Remarks
Exceptions
Type Condition
System.NotSupportedException

When proxying is not allowed (see remarks).

Decorate(IServiceCollection, Type[])

Hooks into the instantiating process to let you decorate the original service. Useful when you want to add additional functionality (e.g. parameter validation).

Declaration
public static IServiceCollection Decorate(this IServiceCollection self, params Type[] interceptors)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Type[] interceptors

The interceptors to be applied.

Returns
Type Description
IServiceCollection
Remarks

Using this method is the preferred way to apply multiple interceptors against the same service as it will only create one backing proxy.

Exceptions
Type Condition
System.NotSupportedException

When proxying is not allowed (see remarks).

Decorate(IServiceCollection, (Type, Object)[])

Hooks into the instantiating process to let you decorate the original service. Useful when you want to add additional functionality (e.g. parameter validation).

Declaration
public static IServiceCollection Decorate(this IServiceCollection self, params (Type, object)[] interceptors)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.ValueTuple<System.Type, System.Object>[] interceptors

The interceptors to be applied.

Returns
Type Description
IServiceCollection
Remarks

Using this method is the preferred way to apply multiple interceptors against the same service as it will only create one backing proxy.

Exceptions
Type Condition
System.NotSupportedException

When proxying is not allowed (see remarks).

Decorate<TInterceptor>(IServiceCollection)

Hooks into the instantiating process to let you decorate the original service. Useful when you want to add additional functionality (e.g. parameter validation).

Declaration
public static IServiceCollection Decorate<TInterceptor>(this IServiceCollection self)
    where TInterceptor : IInterfaceInterceptor
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

Returns
Type Description
IServiceCollection
Type Parameters
Name Description
TInterceptor
Remarks
Exceptions
Type Condition
System.NotSupportedException

When proxying is not allowed (see remarks).

Decorate<TType, TInterceptor>(IServiceCollection)

Hooks into the instantiating process to let you decorate the original service. Useful when you want to add additional functionality (e.g. parameter validation).

Declaration
public static IServiceCollection Decorate<TType, TInterceptor>(this IServiceCollection self)
    where TType : class where TInterceptor : IInterfaceInterceptor
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

Returns
Type Description
IServiceCollection
Type Parameters
Name Description
TType
TInterceptor
Remarks
Exceptions
Type Condition
System.NotSupportedException

When proxying is not allowed (see remarks).

Decorate<TType, TInterceptor>(IServiceCollection, Object)

Hooks into the instantiating process to let you decorate the original service. Useful when you want to add additional functionality (e.g. parameter validation).

Declaration
public static IServiceCollection Decorate<TType, TInterceptor>(this IServiceCollection self, object key)
    where TType : class where TInterceptor : IInterfaceInterceptor
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Object key

The (optional) service key (usually a name).

Returns
Type Description
IServiceCollection
Type Parameters
Name Description
TType
TInterceptor
Remarks
Exceptions
Type Condition
System.NotSupportedException

When proxying is not allowed (see remarks).

Decorate<TType, TInterceptor>(IServiceCollection, Object, Object)

Hooks into the instantiating process to let you decorate the original service. Useful when you want to add additional functionality (e.g. parameter validation).

Declaration
public static IServiceCollection Decorate<TType, TInterceptor>(this IServiceCollection self, object key, object explicitArgs)
    where TType : class where TInterceptor : IInterfaceInterceptor
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Object key

The (optional) service key (usually a name).

System.Object explicitArgs

Explicit arguments to be passed.

Returns
Type Description
IServiceCollection
Type Parameters
Name Description
TType
TInterceptor
Remarks
Exceptions
Type Condition
System.NotSupportedException

When proxying is not allowed (see remarks).

Instance(IServiceCollection, Type, Object, ServiceOptions)

Registers a pre-created instance. Useful to creating "constant" values (e.g. command-line arguments).

Declaration
public static IServiceCollection Instance(this IServiceCollection self, Type type, object instance, ServiceOptions options = null)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Type type

The service type to be registered. It can not be null and can be registered only once.

System.Object instance

The pre-created instance to be registered. It can not be null and must implement the type interface.

ServiceOptions options

Options to be assigned to the service being registered.

Returns
Type Description
IServiceCollection

Instance(IServiceCollection, Type, Object, Object, ServiceOptions)

Registers a pre-created instance. Useful to creating "constant" values (e.g. command-line arguments).

Declaration
public static IServiceCollection Instance(this IServiceCollection self, Type type, object key, object instance, ServiceOptions options = null)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Type type

The service type to be registered. It can not be null and can be registered only once (with the given key).

System.Object key

The (optional) service key (usually a name).

System.Object instance

The pre-created instance to be registered. It can not be null and must implement the type interface.

ServiceOptions options

Options to be assigned to the service being registered.

Returns
Type Description
IServiceCollection

Instance<TType>(IServiceCollection, TType, ServiceOptions)

Registers a pre-created instance. Useful when creating "constant" values (e.g. from command-line arguments).

Declaration
public static IServiceCollection Instance<TType>(this IServiceCollection self, TType instance, ServiceOptions options = null)
    where TType : class
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

TType instance

The pre-created instance to be registered.

ServiceOptions options

Options to be assigned to the service being registered.

Returns
Type Description
IServiceCollection
Type Parameters
Name Description
TType

The service type to be registered. It can be registered only once.

Instance<TType>(IServiceCollection, Object, TType, ServiceOptions)

Registers a pre-created instance. Useful when creating "constant" values (e.g. from command-line arguments).

Declaration
public static IServiceCollection Instance<TType>(this IServiceCollection self, object key, TType instance, ServiceOptions options = null)
    where TType : class
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Object key

The (optional) service key (usually a name).

TType instance

The pre-created instance to be registered.

ServiceOptions options

Options to be assigned to the service being registered.

Returns
Type Description
IServiceCollection
Type Parameters
Name Description
TType

The service type to be registered. It can be registered only once (with the given key).

SetupScopeLocal(IServiceCollection, Type)

Registers a slot for a scope-local variable. Scope-locals are instances (for example the HTTP request object) provided by the current session.

Declaration
public static IServiceCollection SetupScopeLocal(this IServiceCollection self, Type type)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Type type

The service type to be registered. It can not be null and can be registered only once.

Returns
Type Description
IServiceCollection

SetupScopeLocal(IServiceCollection, Type, Object)

Registers a slot for a scope-local variable. Scope-locals are instances (for example the HTTP request object) provided by the current session.

Declaration
public static IServiceCollection SetupScopeLocal(this IServiceCollection self, Type type, object key)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Type type

The service type to be registered. It can not be null and can be registered only once (with the given key).

System.Object key

The (optional) service key (usually a name).

Returns
Type Description
IServiceCollection

SetupScopeLocal<TType>(IServiceCollection)

Registers a slot for a scope-local variable. Scope-locals are instances (for example the HTTP request object) provided by the current session.

Declaration
public static IServiceCollection SetupScopeLocal<TType>(this IServiceCollection self)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

Returns
Type Description
IServiceCollection
Type Parameters
Name Description
TType

SetupScopeLocal<TType>(IServiceCollection, Object)

Registers a slot for a scope-local variable. Scope-locals are instances (for example the HTTP request object) provided by the current session.

Declaration
public static IServiceCollection SetupScopeLocal<TType>(this IServiceCollection self, object key)
Parameters
Type Name Description
IServiceCollection self

The target IServiceCollection.

System.Object key

The (optional) service key (usually a name).

Returns
Type Description
IServiceCollection
Type Parameters
Name Description
TType
In This Article
Back to top Generated by DocFX