Click or drag to resize

RegistrationExtensionsRegisterDecoratorTService Method (ContainerBuilder, FuncIComponentContext, IEnumerableParameter, TService, TService, Object, Object)

Decorate all components implementing service TService using the provided decorator function. The fromKey and toKey parameters must be different values.

Namespace:  Autofac
Assembly:  Autofac (in Autofac.dll) Version: 6.0.0+39696a967e8826f7f1ebc8c1ff4523c9dd75abe0
Syntax
public static IRegistrationBuilder<TService, LightweightAdapterActivatorData, DynamicRegistrationStyle> RegisterDecorator<TService>(
	this ContainerBuilder builder,
	Func<IComponentContext, IEnumerable<Parameter>, TService, TService> decorator,
	Object fromKey,
	Object toKey = null
)

Parameters

builder
Type: AutofacContainerBuilder
Container builder.
decorator
Type: SystemFuncIComponentContext, IEnumerableParameter, TService, TService
Function decorating a component instance that provides TService, given the context and parameters.
fromKey
Type: SystemObject
Service key or name associated with the components being decorated.
toKey (Optional)
Type: SystemObject
Service key or name given to the decorated components.

Type Parameters

TService
Service type being decorated.

Return Value

Type: IRegistrationBuilderTService, LightweightAdapterActivatorData, DynamicRegistrationStyle

[Missing <returns> documentation for "M:Autofac.RegistrationExtensions.RegisterDecorator``1(Autofac.ContainerBuilder,System.Func{Autofac.IComponentContext,System.Collections.Generic.IEnumerable{Autofac.Core.Parameter},``0,``0},System.Object,System.Object)"]

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ContainerBuilder. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also