Click or drag to resize

ComponentRegistrarSetLifetimeScopeTReflectionActivatorData, TSingleRegistrationStyle Method

Sets the lifetime scope for the component.

Namespace:  Autofac.Configuration.Core
Assembly:  Autofac.Configuration (in Autofac.Configuration.dll) Version: 6.0.0+ec1c6438ceb3f3338c7364e35e7303f014e3fc39
Syntax
protected virtual void SetLifetimeScope<TReflectionActivatorData, TSingleRegistrationStyle>(
	IConfiguration component,
	IRegistrationBuilder<Object, TReflectionActivatorData, TSingleRegistrationStyle> registrar
)
where TReflectionActivatorData : ReflectionActivatorData
where TSingleRegistrationStyle : SingleRegistrationStyle

Parameters

component
Type: IConfiguration
The configuration data containing the component. The instanceScope content will be read from this configuration object and used as the lifetime scope.
registrar
Type: Autofac.BuilderIRegistrationBuilderObject, TReflectionActivatorData, TSingleRegistrationStyle
The component registration on which the lifetime scope is being set.

Type Parameters

TReflectionActivatorData
Activator data type.
TSingleRegistrationStyle
Registration style.
Exceptions
ExceptionCondition
ArgumentNullException Thrown if registrar or component is .
InvalidOperationException Thrown if the value for lifetime scope is not part of the recognized grammar.
Remarks

By default, this implementation understands the following grammar:

ValuesLifetime Scope
, emptyDefault - no specified scope
single-instance, SingleInstanceSingleton
instance-per-lifetime-scope, InstancePerLifetimeScope, per-lifetime-scope, PerLifetimeScopeOne instance per nested lifetime scope
instance-per-dependency, InstancePerDependency, per-dependency, PerDependencyOne instance for each resolution call
instance-per-request, InstancePerRequest, per-request, PerRequestOne instance per request lifetime scope

You may override this method to extend the available grammar for lifetime scope.

See Also