Dela via


DependencyInjectionExtensions.AddPool Method

Definition

Overloads

AddPool<TDefinition,TImplementation>(IServiceCollection, Action<PoolOptions>)

Adds an ObjectPool<T> and let DI return scoped instances of T.

AddPool<TDefinition>(IServiceCollection, Action<PoolOptions>)

Adds an ObjectPool<T> and lets DI return scoped instances of T.

AddPool<TDefinition,TImplementation>(IServiceCollection, Action<PoolOptions>)

Adds an ObjectPool<T> and let DI return scoped instances of T.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddPool<TDefinition,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<Microsoft.Extensions.DependencyInjection.Pools.PoolOptions>? configure = default) where TDefinition : class where TImplementation : class, TDefinition;
static member AddPool : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<Microsoft.Extensions.DependencyInjection.Pools.PoolOptions> -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Definition : null)
<Extension()>
Public Function AddPool(Of TDefinition As Class, TImplementation As Class) (services As IServiceCollection, Optional configure As Action(Of PoolOptions) = Nothing) As IServiceCollection

Type Parameters

TDefinition

The type of objects to pool.

TImplementation

The type of the implementation to use.

Parameters

services
IServiceCollection

The IServiceCollection to add to.

configure
Action<PoolOptions>

Configuration of the pool.

Returns

Provided service collection.

Exceptions

When services is null.

Remarks

The default capacity is 1024. The pooled type instances are obtainable the same way like any other type instances from the DI container.

Applies to

AddPool<TDefinition>(IServiceCollection, Action<PoolOptions>)

Adds an ObjectPool<T> and lets DI return scoped instances of T.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddPool<TDefinition>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<Microsoft.Extensions.DependencyInjection.Pools.PoolOptions>? configure = default) where TDefinition : class;
static member AddPool : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<Microsoft.Extensions.DependencyInjection.Pools.PoolOptions> -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Definition : null)
<Extension()>
Public Function AddPool(Of TDefinition As Class) (services As IServiceCollection, Optional configure As Action(Of PoolOptions) = Nothing) As IServiceCollection

Type Parameters

TDefinition

The type of objects to pool.

Parameters

services
IServiceCollection

The IServiceCollection to add to.

configure
Action<PoolOptions>

The action used to configure the options of the pool.

Returns

Provided service collection.

Exceptions

When services is null.

Remarks

The default capacity is 1024. The pooled type instances are obtainable the same way like any other type instances from the DI container.

Applies to