Dela via


NamedServiceCollectionExtensions.AddNamedSingleton Method

Definition

Overloads

AddNamedSingleton<TService,TImplementation>(IServiceCollection, String)

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

AddNamedSingleton<TService>(IServiceCollection, String)

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

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

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

AddNamedSingleton<TService,TImplementation>(IServiceCollection, String)

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

public:
generic <typename TService, typename TImplementation>
 where TService : class where TImplementation : TService[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddNamedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ serviceCollection, System::String ^ name);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddNamedSingleton<TService,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, string name) where TService : class where TImplementation : TService;
static member AddNamedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * string -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddNamedSingleton(Of TService As Class, TImplementation As Class) (serviceCollection As IServiceCollection, name As String) As IServiceCollection

Type Parameters

TService

The type of the service to add.

TImplementation

The type of the implementation to use.

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

AddNamedSingleton<TService>(IServiceCollection, String)

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

public:
generic <typename TService>
 where TService : class[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddNamedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ serviceCollection, System::String ^ name);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddNamedSingleton<TService>(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, string name) where TService : class;
static member AddNamedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * string -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddNamedSingleton(Of TService As Class) (serviceCollection As IServiceCollection, name As String) As IServiceCollection

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

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

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

public:
generic <typename TService>
 where TService : class[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddNamedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ serviceCollection, System::String ^ name, Func<IServiceProvider ^, TService> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddNamedSingleton<TService>(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, string name, Func<IServiceProvider,TService> implementationFactory) where TService : class;
static member AddNamedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * string * Func<IServiceProvider, 'Service (requires 'Service : null)> -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddNamedSingleton(Of TService As Class) (serviceCollection As IServiceCollection, name As String, implementationFactory As Func(Of IServiceProvider, TService)) As IServiceCollection

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