共用方式為


AutoActivationExtensions.TryAddActivatedSingleton 方法

定義

多載

TryAddActivatedSingleton(IServiceCollection, Type)

嘗試新增自動啟用的單一服務。

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

嘗試新增自動啟用的單一服務。

TryAddActivatedSingleton(IServiceCollection, Type, Type)

嘗試新增自動啟用的單一服務。

TryAddActivatedSingleton<TService,TImplementation>(IServiceCollection)

嘗試新增自動啟用的單一服務。

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

嘗試新增自動啟用的單一服務。

TryAddActivatedSingleton<TService>(IServiceCollection)

嘗試新增自動啟用的單一服務。

TryAddActivatedSingleton(IServiceCollection, Type)

來源:
AutoActivationExtensions.cs

嘗試新增自動啟用的單一服務。

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

參數

services
IServiceCollection

要加入服務的服務集合。

serviceType
Type

要註冊的服務類型。

適用於

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

來源:
AutoActivationExtensions.cs

嘗試新增自動啟用的單一服務。

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

參數

services
IServiceCollection

要加入服務的服務集合。

serviceType
Type

要註冊的服務類型。

implementationFactory
Func<IServiceProvider,Object>

建立服務的 Factory。

適用於

TryAddActivatedSingleton(IServiceCollection, Type, Type)

來源:
AutoActivationExtensions.cs

嘗試新增自動啟用的單一服務。

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

參數

services
IServiceCollection

要加入服務的服務集合。

serviceType
Type

要註冊的服務類型。

implementationType
Type

服務的實作類型。

適用於

TryAddActivatedSingleton<TService,TImplementation>(IServiceCollection)

來源:
AutoActivationExtensions.cs

嘗試新增自動啟用的單一服務。

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

類型參數

TService

要新增的服務類型。

TImplementation

要使用的實作類型。

參數

services
IServiceCollection

要加入服務的服務集合。

適用於

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

來源:
AutoActivationExtensions.cs

嘗試新增自動啟用的單一服務。

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

類型參數

TService

要新增的服務類型。

參數

services
IServiceCollection

要加入服務的服務集合。

implementationFactory
Func<IServiceProvider,TService>

建立服務的 Factory。

適用於

TryAddActivatedSingleton<TService>(IServiceCollection)

來源:
AutoActivationExtensions.cs

嘗試新增自動啟用的單一服務。

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

類型參數

TService

要新增的服務類型。

參數

services
IServiceCollection

要加入服務的服務集合。

適用於