Click or drag to resize

RegistrationExtensionsRegisterInstanceT Method

Register an instance as a component.

Namespace:  Autofac
Assembly:  Autofac (in Autofac.dll) Version: 4.9.1+831973f4d02fbc619921dfaa8ac0c536f60ae7a3
Syntax
public static IRegistrationBuilder<T, SimpleActivatorData, SingleRegistrationStyle> RegisterInstance<T>(
	this ContainerBuilder builder,
	T instance
)
where T : class

Parameters

builder
Type: AutofacContainerBuilder
Container builder.
instance
Type: T
The instance to register.

Type Parameters

T
The type of the instance.

Return Value

Type: IRegistrationBuilderT, SimpleActivatorData, SingleRegistrationStyle
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).
Remarks
If no services are explicitly specified for the instance, the static type T will be used as the default service (i.e. *not* instance.GetType()).
See Also