AutoActivationExtensions.TryAddActivatedSingleton Method

Definition

Overloads

TryAddActivatedSingleton(IServiceCollection, Type)

Tries to add an auto-activated singleton service.

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

Tries to add an auto-activated singleton service.

TryAddActivatedSingleton(IServiceCollection, Type, Type)

Tries to add an auto-activated singleton service.

TryAddActivatedSingleton<TService,TImplementation>(IServiceCollection)

Tries to add an auto-activated singleton service.

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

Tries to add an auto-activated singleton service.

TryAddActivatedSingleton<TService>(IServiceCollection)

Tries to add an auto-activated singleton service.

TryAddActivatedSingleton(IServiceCollection, Type)

Source:
AutoActivationExtensions.cs

Tries to add an auto-activated singleton service.

C#
public static void TryAddActivatedSingleton(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType);

Parameters

services
IServiceCollection

The service collection to add the service to.

serviceType
Type

The type of the service to register.

Applies to

.NET 10 (package-provided) dan versi lain
Produk Versi
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)

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

Source:
AutoActivationExtensions.cs

Tries to add an auto-activated singleton service.

C#
public static void TryAddActivatedSingleton(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType, Func<IServiceProvider,object> implementationFactory);

Parameters

services
IServiceCollection

The service collection to add the service to.

serviceType
Type

The type of the service to register.

implementationFactory
Func<IServiceProvider,Object>

The factory that creates the service.

Applies to

.NET 10 (package-provided) dan versi lain
Produk Versi
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)

TryAddActivatedSingleton(IServiceCollection, Type, Type)

Source:
AutoActivationExtensions.cs

Tries to add an auto-activated singleton service.

C#
public static void TryAddActivatedSingleton(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType, Type implementationType);

Parameters

services
IServiceCollection

The service collection to add the service to.

serviceType
Type

The type of the service to register.

implementationType
Type

The implementation type of the service.

Applies to

.NET 10 (package-provided) dan versi lain
Produk Versi
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)

TryAddActivatedSingleton<TService,TImplementation>(IServiceCollection)

Source:
AutoActivationExtensions.cs

Tries to add an auto-activated singleton service.

C#
public static void TryAddActivatedSingleton<TService,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) where TService : class where TImplementation : class, TService;

Type Parameters

TService

The type of the service to add.

TImplementation

The type of the implementation to use.

Parameters

services
IServiceCollection

The service collection to add the service to.

Applies to

.NET 10 (package-provided) dan versi lain
Produk Versi
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)

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

Source:
AutoActivationExtensions.cs

Tries to add an auto-activated singleton service.

C#
public static void TryAddActivatedSingleton<TService>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Func<IServiceProvider,TService> implementationFactory) where TService : class;

Type Parameters

TService

The type of the service to add.

Parameters

services
IServiceCollection

The service collection to add the service to.

implementationFactory
Func<IServiceProvider,TService>

The factory that creates the service.

Applies to

.NET 10 (package-provided) dan versi lain
Produk Versi
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)

TryAddActivatedSingleton<TService>(IServiceCollection)

Source:
AutoActivationExtensions.cs

Tries to add an auto-activated singleton service.

C#
public static void TryAddActivatedSingleton<TService>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) where TService : class;

Type Parameters

TService

The type of the service to add.

Parameters

services
IServiceCollection

The service collection to add the service to.

Applies to

.NET 10 (package-provided) dan versi lain
Produk Versi
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)