NamedServiceCollectionExtensions.AddNamedTransient Method

Definition

Overloads

AddNamedTransient<TService>(IServiceCollection, String)

Adds a transient named service of the type specific in TService to the specified IServiceCollection.

AddNamedTransient<TService>(IServiceCollection, String, Func<IServiceProvider,TService>)

Adds a transient named service of the type specific in TService to the specified IServiceCollection.

AddNamedTransient<TService>(IServiceCollection, String)

Adds a transient named service of the type specific in TService to the specified IServiceCollection.

C#
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddNamedTransient<TService>(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, string name) where TService : class;

Type Parameters

TService

The type of the service to add.

Parameters

serviceCollection
IServiceCollection

The IServiceCollection to add the service to.

name
String

The name of the service.

Returns

A reference to this instance after the operation has completed.

Applies to

.NET 10 (package-provided) dan versi lain
Produk Versi
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)

AddNamedTransient<TService>(IServiceCollection, String, Func<IServiceProvider,TService>)

Adds a transient named service of the type specific in TService to the specified IServiceCollection.

C#
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddNamedTransient<TService>(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, string name, Func<IServiceProvider,TService> implementationFactory) where TService : class;

Type Parameters

TService

The type of the service to add.

Parameters

serviceCollection
IServiceCollection

The IServiceCollection to add the service to.

name
String

The name of the service.

implementationFactory
Func<IServiceProvider,TService>

The factory that creates the service.

Returns

A reference to this instance after the operation has completed.

Applies to

.NET 10 (package-provided) dan versi lain
Produk Versi
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)