RegistrationExtensionsPooledInstancePerLifetimeScopeTLimit, TActivatorData, TSingleRegistrationStyle Method (IRegistrationBuilderTLimit, TActivatorData, TSingleRegistrationStyle, IPooledRegistrationPolicyTLimit) |
Configure the component so that every dependent component or manual resolve within a single
ILifetimeScope
will return the same, shared instance, retrieved from a single pool of instances shared by all lifetime scopes.
When the scope ends, the instance will be returned to the pool.
Namespace:
Autofac.Pooling
Assembly:
Autofac.Pooling (in Autofac.Pooling.dll) Version: 1.0.1+e2b1e849d21d04643649a531a7435392bb1a29cd
Syntax public static IRegistrationBuilder<TLimit, TActivatorData, TSingleRegistrationStyle> PooledInstancePerLifetimeScope<TLimit, TActivatorData, TSingleRegistrationStyle>(
this IRegistrationBuilder<TLimit, TActivatorData, TSingleRegistrationStyle> registration,
IPooledRegistrationPolicy<TLimit> poolPolicy
)
where TLimit : class
where TActivatorData : IConcreteActivatorData
where TSingleRegistrationStyle : SingleRegistrationStyle
<ExtensionAttribute>
Public Shared Function PooledInstancePerLifetimeScope(Of TLimit As Class, TActivatorData As IConcreteActivatorData, TSingleRegistrationStyle As SingleRegistrationStyle) (
registration As IRegistrationBuilder(Of TLimit, TActivatorData, TSingleRegistrationStyle),
poolPolicy As IPooledRegistrationPolicy(Of TLimit)
) As IRegistrationBuilder(Of TLimit, TActivatorData, TSingleRegistrationStyle)
Parameters
- registration
- Type: Autofac.BuilderIRegistrationBuilderTLimit, TActivatorData, TSingleRegistrationStyle
The registration. - poolPolicy
- Type: Autofac.PoolingIPooledRegistrationPolicyTLimit
A custom policy for controlling pool behaviour.
Type Parameters
- TLimit
- Registration limit type.
- TActivatorData
- Activator data type.
- TSingleRegistrationStyle
- Registration style.
Return Value
Type:
IRegistrationBuilderTLimit,
TActivatorData,
TSingleRegistrationStyleThe registration builder.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
IRegistrationBuilderTLimit,
TActivatorData,
TSingleRegistrationStyle. 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
This method accepts a custom IPooledRegistrationPolicyTPooledObject that provides fine-grained control of the retrieval
of instances from the pool, and allows the implementer to choose whether or not the instance should even be returned to the pool.
The size of the pool created with this method is equal to the MaximumRetained value on the
poolPolicy.
If more instances are requested than the pool size, those instances may not be returned to the pool, but will instead be disposed/discarded.
See Also