Click or drag to resize

RegistrationExtensionsPooledInstancePerMatchingLifetimeScopeTLimit, TActivatorData, TSingleRegistrationStyle Method (IRegistrationBuilderTLimit, TActivatorData, TSingleRegistrationStyle, IPooledRegistrationPolicyTLimit, Object)

Configure the component so that every dependent component or manual resolve within a ILifetimeScope tagged with any of the provided tags value gets 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. Dependent components in lifetime scopes that are children of the tagged scope will share the parent's instance. If no appropriately tagged scope can be found in the hierarchy an DependencyResolutionException is thrown.

Namespace:  Autofac.Pooling
Assembly:  Autofac.Pooling (in Autofac.Pooling.dll) Version: 1.0.1+e2b1e849d21d04643649a531a7435392bb1a29cd
public static IRegistrationBuilder<TLimit, TActivatorData, TSingleRegistrationStyle> PooledInstancePerMatchingLifetimeScope<TLimit, TActivatorData, TSingleRegistrationStyle>(
	this IRegistrationBuilder<TLimit, TActivatorData, TSingleRegistrationStyle> registration,
	IPooledRegistrationPolicy<TLimit> poolPolicy,
	params Object[] lifetimeScopeTags
where TLimit : class
where TActivatorData : IConcreteActivatorData
where TSingleRegistrationStyle : SingleRegistrationStyle


Type: Autofac.BuilderIRegistrationBuilderTLimit, TActivatorData, TSingleRegistrationStyle
The registration.
Type: Autofac.PoolingIPooledRegistrationPolicyTLimit
A custom policy for controlling pool behaviour.
Type: SystemObject
Tags applied to matching lifetime scopes.

Type Parameters

Registration limit type.
Activator data type.
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).

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