แชร์ผ่าน


ObjectPoolServiceCollectionExtensions.AddPooled Method

Definition

Overloads

AddPooled<TService,TImplementation>(IServiceCollection, Action<DependencyInjectionPoolOptions>)

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

AddPooled<TService>(IServiceCollection, Action<DependencyInjectionPoolOptions>)

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

AddPooled<TService,TImplementation>(IServiceCollection, Action<DependencyInjectionPoolOptions>)

Source:
ObjectPoolServiceCollectionExtensions.cs

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

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddPooled<TService,TImplementation> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<Microsoft.Extensions.ObjectPool.DependencyInjectionPoolOptions>? configure = default) where TService : class where TImplementation : class, TService;
static member AddPooled : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<Microsoft.Extensions.ObjectPool.DependencyInjectionPoolOptions> -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddPooled(Of TService As Class, TImplementation As Class) (services As IServiceCollection, Optional configure As Action(Of DependencyInjectionPoolOptions) = Nothing) As IServiceCollection

Type Parameters

TService

The type of objects to pool.

TImplementation

The type of the implementation to use.

Parameters

services
IServiceCollection

The IServiceCollection to add to.

configure
Action<DependencyInjectionPoolOptions>

Configuration of the pool.

Returns

Provided service collection.

Exceptions

services is null.

Remarks

The default capacity is 1024. The pooled type instances are obtainable by resolving ObjectPool<T> from the DI container.

Applies to

AddPooled<TService>(IServiceCollection, Action<DependencyInjectionPoolOptions>)

Source:
ObjectPoolServiceCollectionExtensions.cs

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

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddPooled<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<Microsoft.Extensions.ObjectPool.DependencyInjectionPoolOptions>? configure = default) where TService : class;
static member AddPooled : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<Microsoft.Extensions.ObjectPool.DependencyInjectionPoolOptions> -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddPooled(Of TService As Class) (services As IServiceCollection, Optional configure As Action(Of DependencyInjectionPoolOptions) = Nothing) As IServiceCollection

Type Parameters

TService

The type of objects to pool.

Parameters

services
IServiceCollection

The IServiceCollection to add to.

configure
Action<DependencyInjectionPoolOptions>

The action used to configure the options of the pool.

Returns

Provided service collection.

Exceptions

services is null.

Remarks

The default capacity is 1024. The pooled type instances are obtainable by resolving ObjectPool<T> from the DI container.

Applies to