ServiceCollectionDescriptorExtensions.TryAddKeyedSingleton Método
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Sobrecargas
TryAddKeyedSingleton(IServiceCollection, Type, Object) |
Adicionará o |
TryAddKeyedSingleton(IServiceCollection, Type, Object, Func<IServiceProvider,Object,Object>) |
Adicionará o |
TryAddKeyedSingleton(IServiceCollection, Type, Object, Type) |
Adicionará o |
TryAddKeyedSingleton<TService,TImplementation>(IServiceCollection, Object) |
Adicionará o |
TryAddKeyedSingleton<TService>(IServiceCollection, Object) |
Adicionará o |
TryAddKeyedSingleton<TService>(IServiceCollection, Object, Func<IServiceProvider,Object,TService>) |
Adicionará o |
TryAddKeyedSingleton<TService>(IServiceCollection, Object, TService) |
Adicionará o |
TryAddKeyedSingleton(IServiceCollection, Type, Object)
Adicionará o service
especificado como um serviço Singleton à collection
se o tipo de serviço ainda não tiver sido registrado.
public:
[System::Runtime::CompilerServices::Extension]
static void TryAddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, Type ^ service, System::Object ^ serviceKey);
public static void TryAddKeyedSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Type service, object? serviceKey);
static member TryAddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * obj -> unit
<Extension()>
Public Sub TryAddKeyedSingleton (collection As IServiceCollection, service As Type, serviceKey As Object)
Parâmetros
- collection
- IServiceCollection
- service
- Type
O tipo do serviço a ser registrado.
- serviceKey
- Object
A chave de serviço.
Aplica-se a
TryAddKeyedSingleton(IServiceCollection, Type, Object, Func<IServiceProvider,Object,Object>)
Adicionará o service
especificado como um serviço de Singleton usando o alocador especificado em implementationFactory
à collection
se o tipo de serviço ainda não tiver sido registrado.
public:
[System::Runtime::CompilerServices::Extension]
static void TryAddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, Type ^ service, System::Object ^ serviceKey, Func<IServiceProvider ^, System::Object ^, System::Object ^> ^ implementationFactory);
public static void TryAddKeyedSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Type service, object? serviceKey, Func<IServiceProvider,object?,object> implementationFactory);
static member TryAddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * obj * Func<IServiceProvider, obj, obj> -> unit
<Extension()>
Public Sub TryAddKeyedSingleton (collection As IServiceCollection, service As Type, serviceKey As Object, implementationFactory As Func(Of IServiceProvider, Object, Object))
Parâmetros
- collection
- IServiceCollection
- service
- Type
O tipo do serviço a ser registrado.
- serviceKey
- Object
A chave de serviço.
- implementationFactory
- Func<IServiceProvider,Object,Object>
O alocador que cria o serviço.
Aplica-se a
TryAddKeyedSingleton(IServiceCollection, Type, Object, Type)
Adicionará o service
especificado como um serviço Singleton com a implementação de implementationType
à collection
se o tipo de serviço ainda não tiver sido registrado.
public:
[System::Runtime::CompilerServices::Extension]
static void TryAddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, Type ^ service, System::Object ^ serviceKey, Type ^ implementationType);
public static void TryAddKeyedSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Type service, object? serviceKey, Type implementationType);
static member TryAddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * obj * Type -> unit
<Extension()>
Public Sub TryAddKeyedSingleton (collection As IServiceCollection, service As Type, serviceKey As Object, implementationType As Type)
Parâmetros
- collection
- IServiceCollection
- service
- Type
O tipo do serviço a ser registrado.
- serviceKey
- Object
A chave de serviço.
- implementationType
- Type
O tipo de implementação do serviço.
Aplica-se a
TryAddKeyedSingleton<TService,TImplementation>(IServiceCollection, Object)
Adicionará o TService
especificado como um tipo de implementação de serviço de Singleton especificado em TImplementation
à collection
se o tipo de serviço ainda não tiver sido registrado.
public:
generic <typename TService, typename TImplementation>
where TService : class where TImplementation : class, TService[System::Runtime::CompilerServices::Extension]
static void TryAddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, System::Object ^ serviceKey);
public static void TryAddKeyedSingleton<TService,TImplementation> (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, object? serviceKey) where TService : class where TImplementation : class, TService;
static member TryAddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddKeyedSingleton(Of TService As Class, TImplementation As Class) (collection As IServiceCollection, serviceKey As Object)
Parâmetros de tipo
- TService
O tipo do serviço a adicionar.
- TImplementation
O tipo da implementação a ser usada.
Parâmetros
- collection
- IServiceCollection
- serviceKey
- Object
A chave de serviço.
Aplica-se a
TryAddKeyedSingleton<TService>(IServiceCollection, Object)
Adicionará o TService
especificado como um serviço Singleton à collection
se o tipo de serviço ainda não tiver sido registrado.
public:
generic <typename TService>
where TService : class[System::Runtime::CompilerServices::Extension]
static void TryAddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, System::Object ^ serviceKey);
public static void TryAddKeyedSingleton<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, object? serviceKey) where TService : class;
static member TryAddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddKeyedSingleton(Of TService As Class) (collection As IServiceCollection, serviceKey As Object)
Parâmetros de tipo
- TService
O tipo do serviço a adicionar.
Parâmetros
- collection
- IServiceCollection
- serviceKey
- Object
A chave de serviço.
Aplica-se a
TryAddKeyedSingleton<TService>(IServiceCollection, Object, Func<IServiceProvider,Object,TService>)
Adicionará o TService
especificado como um serviço de Singleton usando o alocador especificado em implementationFactory
à services
se o tipo de serviço ainda não tiver sido registrado.
public:
generic <typename TService>
where TService : class[System::Runtime::CompilerServices::Extension]
static void TryAddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::Object ^ serviceKey, Func<IServiceProvider ^, System::Object ^, TService> ^ implementationFactory);
public static void TryAddKeyedSingleton<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, object? serviceKey, Func<IServiceProvider,object?,TService> implementationFactory) where TService : class;
static member TryAddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj * Func<IServiceProvider, obj, 'Service (requires 'Service : null)> -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddKeyedSingleton(Of TService As Class) (services As IServiceCollection, serviceKey As Object, implementationFactory As Func(Of IServiceProvider, Object, TService))
Parâmetros de tipo
- TService
O tipo do serviço a adicionar.
Parâmetros
- services
- IServiceCollection
- serviceKey
- Object
A chave de serviço.
- implementationFactory
- Func<IServiceProvider,Object,TService>
O alocador que cria o serviço.
Aplica-se a
TryAddKeyedSingleton<TService>(IServiceCollection, Object, TService)
Adicionará o TService
especificado como um serviço de Singleton com uma instância especificada em instance
à collection
se o tipo de serviço ainda não tiver sido registrado.
public:
generic <typename TService>
where TService : class[System::Runtime::CompilerServices::Extension]
static void TryAddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, System::Object ^ serviceKey, TService instance);
public static void TryAddKeyedSingleton<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, object? serviceKey, TService instance) where TService : class;
static member TryAddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj * 'Service -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddKeyedSingleton(Of TService As Class) (collection As IServiceCollection, serviceKey As Object, instance As TService)
Parâmetros de tipo
- TService
O tipo do serviço a adicionar.
Parâmetros
- collection
- IServiceCollection
- serviceKey
- Object
A chave de serviço.
- instance
- TService
A instância do serviço a ser adicionada.