ObjectPoolServiceCollectionExtensions.AddPooled Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
AddPooled<TService,TImplementation>(IServiceCollection, Action<DependencyInjectionPoolOptions>) |
Adds an ObjectPool<T> and lets DI return scoped instances of |
AddPooled<TService>(IServiceCollection, Action<DependencyInjectionPoolOptions>) |
Adds an ObjectPool<T> and lets DI return scoped instances of |
AddPooled<TService,TImplementation>(IServiceCollection, Action<DependencyInjectionPoolOptions>)
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>)
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
Feedback
https://aka.ms/ContentUserFeedback.
Binnenkort: Gedurende 2024 worden GitHub Issues uitgefaseerd als het feedbackmechanisme voor inhoud. Dit wordt vervangen door een nieuw feedbacksysteem. Ga voor meer informatie naar:Feedback verzenden en bekijken voor