Click or drag to resize

RegistrationExtensionsRegisterGeneric Method (ContainerBuilder, FuncIComponentContext, Type, Object)

Register a delegate that can provide instances of an open generic registration.

Namespace:  Autofac
Assembly:  Autofac (in Autofac.dll) Version: 6.0.0+39696a967e8826f7f1ebc8c1ff4523c9dd75abe0
Syntax
public static IRegistrationBuilder<Object, OpenGenericDelegateActivatorData, DynamicRegistrationStyle> RegisterGeneric(
	this ContainerBuilder builder,
	Func<IComponentContext, Type[], Object> factory
)

Parameters

builder
Type: AutofacContainerBuilder
The container builder.
factory
Type: SystemFuncIComponentContext, Type, Object
Delegate responsible for generating an instance of a closed generic based on the open generic type being registered. It will be called with the current IComponentContext and the array of generic type arguments expected to be in the closed generic.

Return Value

Type: IRegistrationBuilderObject, OpenGenericDelegateActivatorData, DynamicRegistrationStyle
Registration builder allowing the registration to be configured.

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