Compartir vía


ServiceCollectionServiceExtensions.AddSingleton Método

Definición

Sobrecargas

AddSingleton(IServiceCollection, Type, Object)

Agrega un servicio singleton del tipo especificado en serviceType con una instancia especificada en implementationInstance a la instancia de IServiceCollection especificada.

AddSingleton(IServiceCollection, Type, Type)

Agrega un servicio singleton del tipo especificado en serviceType con una implementación del tipo especificado en implementationType a la instancia de IServiceCollection especificada.

AddSingleton(IServiceCollection, Type)

Agrega un servicio singleton del tipo especificado en serviceType a la instancia de IServiceCollection especificada.

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

Agrega un servicio singleton del tipo especificado en serviceType con un generador especificado en implementationFactory a la instancia de IServiceCollection especificada.

AddSingleton<TService,TImplementation>(IServiceCollection)

Agrega un servicio singleton del tipo especificado en TService con un tipo de implementación especificado en TImplementation a la instancia de IServiceCollection especificada.

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

Agrega un servicio singleton del tipo especificado en TService con un tipo de implementación especificado en TImplementation mediante el generador especificado en implementationFactory a la instancia de IServiceCollection especificada.

AddSingleton<TService>(IServiceCollection)

Agrega un servicio singleton del tipo especificado en TService a la instancia de IServiceCollection especificada.

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

Agrega un servicio singleton del tipo especificado en TService con un generador especificado en implementationFactory a la instancia de IServiceCollection especificada.

AddSingleton<TService>(IServiceCollection, TService)

Agrega un servicio singleton del tipo especificado en TService con una instancia especificada en implementationInstance a la instancia de IServiceCollection especificada.

AddSingleton(IServiceCollection, Type, Object)

Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs

Agrega un servicio singleton del tipo especificado en serviceType con una instancia especificada en implementationInstance a la instancia de IServiceCollection especificada.

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

La interfaz IServiceCollection a la que se va a agregar el servicio.

serviceType
Type

El tipo de servicio que se va a registrar.

implementationInstance
Object

La instancia del servicio.

Devoluciones

Una referencia a esta instancia después de que se haya completado la operación.

Consulte también

Se aplica a

AddSingleton(IServiceCollection, Type, Type)

Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs

Agrega un servicio singleton del tipo especificado en serviceType con una implementación del tipo especificado en implementationType a la instancia de IServiceCollection especificada.

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

La interfaz IServiceCollection a la que se va a agregar el servicio.

serviceType
Type

El tipo de servicio que se va a registrar.

implementationType
Type

El tipo de implementación del servicio.

Devoluciones

Una referencia a esta instancia después de que se haya completado la operación.

Consulte también

Se aplica a

AddSingleton(IServiceCollection, Type)

Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs

Agrega un servicio singleton del tipo especificado en serviceType a la instancia de IServiceCollection especificada.

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

La interfaz IServiceCollection a la que se va a agregar el servicio.

serviceType
Type

El tipo de servicio que se va a registrar y la implementación que se va a usar.

Devoluciones

Una referencia a esta instancia después de que se haya completado la operación.

Consulte también

Se aplica a

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

Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs

Agrega un servicio singleton del tipo especificado en serviceType con un generador especificado en implementationFactory a la instancia de IServiceCollection especificada.

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

La interfaz IServiceCollection a la que se va a agregar el servicio.

serviceType
Type

El tipo de servicio que se va a registrar.

implementationFactory
Func<IServiceProvider,Object>

El generador que crea el servicio.

Devoluciones

Una referencia a esta instancia después de que se haya completado la operación.

Consulte también

Se aplica a

AddSingleton<TService,TImplementation>(IServiceCollection)

Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs

Agrega un servicio singleton del tipo especificado en TService con un tipo de implementación especificado en TImplementation a la instancia de IServiceCollection especificada.

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

El tipo del servicio que se debe agregar.

TImplementation

Tipo de la implementación que se va a usar.

Parámetros

services
IServiceCollection

La interfaz IServiceCollection a la que se va a agregar el servicio.

Devoluciones

Una referencia a esta instancia después de que se haya completado la operación.

Consulte también

Se aplica a

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

Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs

Agrega un servicio singleton del tipo especificado en TService con un tipo de implementación especificado en TImplementation mediante el generador especificado en implementationFactory a la instancia de IServiceCollection especificada.

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

El tipo del servicio que se debe agregar.

TImplementation

Tipo de la implementación que se va a usar.

Parámetros

services
IServiceCollection

La interfaz IServiceCollection a la que se va a agregar el servicio.

implementationFactory
Func<IServiceProvider,TImplementation>

El generador que crea el servicio.

Devoluciones

Una referencia a esta instancia después de que se haya completado la operación.

Consulte también

Se aplica a

AddSingleton<TService>(IServiceCollection)

Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs

Agrega un servicio singleton del tipo especificado en TService a la instancia de IServiceCollection especificada.

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

El tipo del servicio que se debe agregar.

Parámetros

services
IServiceCollection

La interfaz IServiceCollection a la que se va a agregar el servicio.

Devoluciones

Una referencia a esta instancia después de que se haya completado la operación.

Consulte también

Se aplica a

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

Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs

Agrega un servicio singleton del tipo especificado en TService con un generador especificado en implementationFactory a la instancia de IServiceCollection especificada.

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

El tipo del servicio que se debe agregar.

Parámetros

services
IServiceCollection

La interfaz IServiceCollection a la que se va a agregar el servicio.

implementationFactory
Func<IServiceProvider,TService>

El generador que crea el servicio.

Devoluciones

Una referencia a esta instancia después de que se haya completado la operación.

Consulte también

Se aplica a

AddSingleton<TService>(IServiceCollection, TService)

Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs
Source:
ServiceCollectionServiceExtensions.cs

Agrega un servicio singleton del tipo especificado en TService con una instancia especificada en implementationInstance a la instancia de IServiceCollection especificada.

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

La interfaz IServiceCollection a la que se va a agregar el servicio.

implementationInstance
TService

La instancia del servicio.

Devoluciones

Una referencia a esta instancia después de que se haya completado la operación.

Consulte también

Se aplica a