Click or drag to resize

RegistrationExtensionsPooledInstancePerLifetimeScopeTLimit, TActivatorData, TSingleRegistrationStyle Method (IRegistrationBuilderTLimit, TActivatorData, TSingleRegistrationStyle, Int32)

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,
	int maximumRetainedInstances
)
where TLimit : class
where TActivatorData : IConcreteActivatorData
where TSingleRegistrationStyle : SingleRegistrationStyle

Parameters

registration
Type: Autofac.BuilderIRegistrationBuilderTLimit, TActivatorData, TSingleRegistrationStyle
The registration.
maximumRetainedInstances
Type: SystemInt32
The maximum number of instances to retain in the pool.

Type Parameters

TLimit
Registration limit type.
TActivatorData
Activator data type.
TSingleRegistrationStyle
Registration style.

Return Value

Type: IRegistrationBuilderTLimit, TActivatorData, TSingleRegistrationStyle
The 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

The size of the pool created with this method is equal to maximumRetainedInstances. If more instances are requested than the pool size, those instances may not be returned to the pool, but will instead be disposed/discarded.

If a component needs to perform behaviour when it is retrieved from or returned to the pool, it can implement IPooledComponent, or use the overload of this method that accepts a custom IPooledRegistrationPolicyTPooledObject.

See Also