ServiceCollectionDescriptorExtensions.TryAddSingleton 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
TryAddSingleton(IServiceCollection, Type, Type) |
Adicionará o |
TryAddSingleton(IServiceCollection, Type, Func<IServiceProvider,Object>) |
Adicionará o |
TryAddSingleton(IServiceCollection, Type) |
Adicionará o |
TryAddSingleton<TService,TImplementation>(IServiceCollection) |
Adicionará o |
TryAddSingleton<TService>(IServiceCollection) |
Adicionará o |
TryAddSingleton<TService>(IServiceCollection, Func<IServiceProvider,TService>) |
Adicionará o |
TryAddSingleton<TService>(IServiceCollection, TService) |
Adicionará o |
TryAddSingleton(IServiceCollection, Type, 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 TryAddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, Type ^ service, Type ^ implementationType);
public static void TryAddSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Type service, Type implementationType);
static member TryAddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * Type -> unit
<Extension()>
Public Sub TryAddSingleton (collection As IServiceCollection, service As Type, implementationType As Type)
Parâmetros
- collection
- IServiceCollection
- service
- Type
O tipo do serviço a ser registrado.
- implementationType
- Type
O tipo de implementação do serviço.
Aplica-se a
TryAddSingleton(IServiceCollection, Type, Func<IServiceProvider,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 TryAddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, Type ^ service, Func<IServiceProvider ^, System::Object ^> ^ implementationFactory);
public static void TryAddSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Type service, Func<IServiceProvider,object> implementationFactory);
static member TryAddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * Func<IServiceProvider, obj> -> unit
<Extension()>
Public Sub TryAddSingleton (collection As IServiceCollection, service As Type, implementationFactory As Func(Of IServiceProvider, Object))
Parâmetros
- collection
- IServiceCollection
- service
- Type
O tipo do serviço a ser registrado.
- implementationFactory
- Func<IServiceProvider,Object>
O alocador que cria o serviço.
Aplica-se a
TryAddSingleton(IServiceCollection, Type)
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 TryAddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, Type ^ service);
public static void TryAddSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Type service);
static member TryAddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type -> unit
<Extension()>
Public Sub TryAddSingleton (collection As IServiceCollection, service As Type)
Parâmetros
- collection
- IServiceCollection
- service
- Type
O tipo do serviço a ser registrado.
Aplica-se a
TryAddSingleton<TService,TImplementation>(IServiceCollection)
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 TryAddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection);
public static void TryAddSingleton<TService,TImplementation> (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection) where TService : class where TImplementation : class, TService;
static member TryAddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddSingleton(Of TService As Class, TImplementation As Class) (collection As IServiceCollection)
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
Aplica-se a
TryAddSingleton<TService>(IServiceCollection)
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 TryAddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection);
public static void TryAddSingleton<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection) where TService : class;
static member TryAddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddSingleton(Of TService As Class) (collection As IServiceCollection)
Parâmetros de tipo
- TService
O tipo do serviço a adicionar.
Parâmetros
- collection
- IServiceCollection
Aplica-se a
TryAddSingleton<TService>(IServiceCollection, Func<IServiceProvider,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 TryAddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Func<IServiceProvider ^, TService> ^ implementationFactory);
public static void TryAddSingleton<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Func<IServiceProvider,TService> implementationFactory) where TService : class;
static member TryAddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Func<IServiceProvider, 'Service (requires 'Service : null)> -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddSingleton(Of TService As Class) (services As IServiceCollection, implementationFactory As Func(Of IServiceProvider, TService))
Parâmetros de tipo
- TService
O tipo do serviço a adicionar.
Parâmetros
- services
- IServiceCollection
- implementationFactory
- Func<IServiceProvider,TService>
O alocador que cria o serviço.
Aplica-se a
TryAddSingleton<TService>(IServiceCollection, 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 TryAddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, TService instance);
public static void TryAddSingleton<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, TService instance) where TService : class;
static member TryAddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * 'Service -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddSingleton(Of TService As Class) (collection As IServiceCollection, instance As TService)
Parâmetros de tipo
- TService
O tipo do serviço a adicionar.
Parâmetros
- collection
- IServiceCollection
- instance
- TService
A instância do serviço a ser adicionada.