ServiceCollectionServiceExtensions.AddSingleton Método

Definição

Sobrecargas

AddSingleton(IServiceCollection, Type)

Adiciona um serviço de singleton do tipo especificado em serviceType à IServiceCollection especificada.Adds a singleton service of the type specified in serviceType to the specified IServiceCollection.

AddSingleton(IServiceCollection, Type, Func<IServiceProvider,Object>)

Adiciona um serviço de singleton do tipo especificado em serviceType com um alocador especificado em implementationFactory à IServiceCollection especificada.Adds a singleton service of the type specified in serviceType with a factory specified in implementationFactory to the specified IServiceCollection.

AddSingleton(IServiceCollection, Type, Object)

Adiciona um serviço singleton do tipo especificado em serviceType com uma instância especificada em implementationInstance à IServiceCollection especificada.Adds a singleton service of the type specified in serviceType with an instance specified in implementationInstance to the specified IServiceCollection.

AddSingleton(IServiceCollection, Type, Type)

Adiciona um serviço de singleton do tipo especificado em serviceType com uma implementação do tipo especificado em implementationType à IServiceCollection especificada.Adds a singleton service of the type specified in serviceType with an implementation of the type specified in implementationType to the specified IServiceCollection.

AddSingleton<TService,TImplementation>(IServiceCollection, Func<IServiceProvider,TImplementation>)

Adiciona um serviço de singleton do tipo especificado em TService com um tipo de implementação especificado em TImplementation usando o alocador especificado em implementationFactory à IServiceCollection especificada.Adds a singleton service of the type specified in TService with an implementation type specified in TImplementation using the factory specified in implementationFactory to the specified IServiceCollection.

AddSingleton<TService,TImplementation>(IServiceCollection)

Adiciona um serviço de singleton do tipo especificado em TService com um tipo de implementação especificado em TImplementation à IServiceCollection especificada.Adds a singleton service of the type specified in TService with an implementation type specified in TImplementation to the specified IServiceCollection.

AddSingleton<TService>(IServiceCollection)

Adiciona um serviço de singleton do tipo especificado em TService à IServiceCollection especificada.Adds a singleton service of the type specified in TService to the specified IServiceCollection.

AddSingleton<TService>(IServiceCollection, Func<IServiceProvider,TService>)

Adiciona um serviço de singleton do tipo especificado em TService com um alocador especificado em implementationFactory à IServiceCollection especificada.Adds a singleton service of the type specified in TService with a factory specified in implementationFactory to the specified IServiceCollection.

AddSingleton<TService>(IServiceCollection, TService)

Adiciona um serviço singleton do tipo especificado em TService com uma instância especificada em implementationInstance à IServiceCollection especificada.Adds a singleton service of the type specified in TService with an instance specified in implementationInstance to the specified IServiceCollection.

AddSingleton(IServiceCollection, Type)

Adiciona um serviço de singleton do tipo especificado em serviceType à IServiceCollection especificada.Adds a singleton service of the type specified in serviceType to the specified IServiceCollection.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Type ^ serviceType);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType);
static member AddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddSingleton (services As IServiceCollection, serviceType As Type) As IServiceCollection

Parâmetros

services
IServiceCollection

O IServiceCollection ao qual adicionar o serviço.The IServiceCollection to add the service to.

serviceType
Type

O tipo de serviço a ser registrado e a implementação a ser usada.The type of the service to register and the implementation to use.

Retornos

IServiceCollection

Uma referência a essa instância após a operação ter sido concluída.A reference to this instance after the operation has completed.

Confira também

Aplica-se a

AddSingleton(IServiceCollection, Type, Func<IServiceProvider,Object>)

Adiciona um serviço de singleton do tipo especificado em serviceType com um alocador especificado em implementationFactory à IServiceCollection especificada.Adds a singleton service of the type specified in serviceType with a factory specified in implementationFactory to the specified IServiceCollection.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Type ^ serviceType, Func<IServiceProvider ^, System::Object ^> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType, Func<IServiceProvider,object> implementationFactory);
static member AddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * Func<IServiceProvider, obj> -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddSingleton (services As IServiceCollection, serviceType As Type, implementationFactory As Func(Of IServiceProvider, Object)) As IServiceCollection

Parâmetros

services
IServiceCollection

O IServiceCollection ao qual adicionar o serviço.The IServiceCollection to add the service to.

serviceType
Type

O tipo do serviço a ser registrado.The type of the service to register.

implementationFactory
Func<IServiceProvider,Object>

O alocador que cria o serviço.The factory that creates the service.

Retornos

IServiceCollection

Uma referência a essa instância após a operação ter sido concluída.A reference to this instance after the operation has completed.

Confira também

Aplica-se a

AddSingleton(IServiceCollection, Type, Object)

Adiciona um serviço singleton do tipo especificado em serviceType com uma instância especificada em implementationInstance à IServiceCollection especificada.Adds a singleton service of the type specified in serviceType with an instance specified in implementationInstance to the specified IServiceCollection.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Type ^ serviceType, System::Object ^ implementationInstance);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType, object implementationInstance);
static member AddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * obj -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddSingleton (services As IServiceCollection, serviceType As Type, implementationInstance As Object) As IServiceCollection

Parâmetros

services
IServiceCollection

O IServiceCollection ao qual adicionar o serviço.The IServiceCollection to add the service to.

serviceType
Type

O tipo do serviço a ser registrado.The type of the service to register.

implementationInstance
Object

Uma instância do serviço.The instance of the service.

Retornos

IServiceCollection

Uma referência a essa instância após a operação ter sido concluída.A reference to this instance after the operation has completed.

Confira também

Aplica-se a

AddSingleton(IServiceCollection, Type, Type)

Adiciona um serviço de singleton do tipo especificado em serviceType com uma implementação do tipo especificado em implementationType à IServiceCollection especificada.Adds a singleton service of the type specified in serviceType with an implementation of the type specified in implementationType to the specified IServiceCollection.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Type ^ serviceType, Type ^ implementationType);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType, Type implementationType);
static member AddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * Type -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddSingleton (services As IServiceCollection, serviceType As Type, implementationType As Type) As IServiceCollection

Parâmetros

services
IServiceCollection

O IServiceCollection ao qual adicionar o serviço.The IServiceCollection to add the service to.

serviceType
Type

O tipo do serviço a ser registrado.The type of the service to register.

implementationType
Type

O tipo de implementação do serviço.The implementation type of the service.

Retornos

IServiceCollection

Uma referência a essa instância após a operação ter sido concluída.A reference to this instance after the operation has completed.

Confira também

Aplica-se a

AddSingleton<TService,TImplementation>(IServiceCollection, Func<IServiceProvider,TImplementation>)

Adiciona um serviço de singleton do tipo especificado em TService com um tipo de implementação especificado em TImplementation usando o alocador especificado em implementationFactory à IServiceCollection especificada.Adds a singleton service of the type specified in TService with an implementation type specified in TImplementation using the factory specified in implementationFactory to the specified IServiceCollection.

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

Parâmetros de tipo

TService

O tipo do serviço a adicionar.The type of the service to add.

TImplementation

O tipo de implementação a ser usado.The type of the implementation to use.

Parâmetros

services
IServiceCollection

O IServiceCollection ao qual adicionar o serviço.The IServiceCollection to add the service to.

implementationFactory
Func<IServiceProvider,TImplementation>

O alocador que cria o serviço.The factory that creates the service.

Retornos

IServiceCollection

Uma referência a essa instância após a operação ter sido concluída.A reference to this instance after the operation has completed.

Confira também

Aplica-se a

AddSingleton<TService,TImplementation>(IServiceCollection)

Adiciona um serviço de singleton do tipo especificado em TService com um tipo de implementação especificado em TImplementation à IServiceCollection especificada.Adds a singleton service of the type specified in TService with an implementation type specified in TImplementation to the specified IServiceCollection.

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

Parâmetros de tipo

TService

O tipo do serviço a adicionar.The type of the service to add.

TImplementation

O tipo de implementação a ser usado.The type of the implementation to use.

Parâmetros

services
IServiceCollection

O IServiceCollection ao qual adicionar o serviço.The IServiceCollection to add the service to.

Retornos

IServiceCollection

Uma referência a essa instância após a operação ter sido concluída.A reference to this instance after the operation has completed.

Confira também

Aplica-se a

AddSingleton<TService>(IServiceCollection)

Adiciona um serviço de singleton do tipo especificado em TService à IServiceCollection especificada.Adds a singleton service of the type specified in TService to the specified IServiceCollection.

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

Parâmetros de tipo

TService

O tipo do serviço a adicionar.The type of the service to add.

Parâmetros

services
IServiceCollection

O IServiceCollection ao qual adicionar o serviço.The IServiceCollection to add the service to.

Retornos

IServiceCollection

Uma referência a essa instância após a operação ter sido concluída.A reference to this instance after the operation has completed.

Confira também

Aplica-se a

AddSingleton<TService>(IServiceCollection, Func<IServiceProvider,TService>)

Adiciona um serviço de singleton do tipo especificado em TService com um alocador especificado em implementationFactory à IServiceCollection especificada.Adds a singleton service of the type specified in TService with a factory specified in implementationFactory to the specified IServiceCollection.

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

Parâmetros de tipo

TService

O tipo do serviço a adicionar.The type of the service to add.

Parâmetros

services
IServiceCollection

O IServiceCollection ao qual adicionar o serviço.The IServiceCollection to add the service to.

implementationFactory
Func<IServiceProvider,TService>

O alocador que cria o serviço.The factory that creates the service.

Retornos

IServiceCollection

Uma referência a essa instância após a operação ter sido concluída.A reference to this instance after the operation has completed.

Confira também

Aplica-se a

AddSingleton<TService>(IServiceCollection, TService)

Adiciona um serviço singleton do tipo especificado em TService com uma instância especificada em implementationInstance à IServiceCollection especificada.Adds a singleton service of the type specified in TService with an instance specified in implementationInstance to the specified IServiceCollection.

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

Parâmetros de tipo

TService

Parâmetros

services
IServiceCollection

O IServiceCollection ao qual adicionar o serviço.The IServiceCollection to add the service to.

implementationInstance
TService

Uma instância do serviço.The instance of the service.

Retornos

IServiceCollection

Uma referência a essa instância após a operação ter sido concluída.A reference to this instance after the operation has completed.

Confira também

Aplica-se a