共用方式為


AutoActivationExtensions.TryAddActivatedKeyedSingleton 方法

定義

多載

TryAddActivatedKeyedSingleton(IServiceCollection, Type, Object)

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

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

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

TryAddActivatedKeyedSingleton(IServiceCollection, Type, Object, Type)

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

TryAddActivatedKeyedSingleton<TService,TImplementation>(IServiceCollection, Object)

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

TryAddActivatedKeyedSingleton<TService>(IServiceCollection, Object)

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

TryAddActivatedKeyedSingleton<TService>(IServiceCollection, Object, Func<IServiceProvider,Object,TService>)

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

TryAddActivatedKeyedSingleton(IServiceCollection, Type, Object)

來源:
AutoActivationExtensions.Keyed.cs
來源:
AutoActivationExtensions.Keyed.cs

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

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

參數

services
IServiceCollection

要加入服務的服務集合。

serviceType
Type

要註冊的服務類型。

serviceKey
Object

用來唯一識別特定服務的物件。

適用於

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

來源:
AutoActivationExtensions.Keyed.cs
來源:
AutoActivationExtensions.Keyed.cs

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

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

參數

services
IServiceCollection

要加入服務的服務集合。

serviceType
Type

要註冊的服務類型。

serviceKey
Object

用來唯一識別特定服務的物件。

implementationFactory
Func<IServiceProvider,Object,Object>

建立服務的 Factory。

適用於

TryAddActivatedKeyedSingleton(IServiceCollection, Type, Object, Type)

來源:
AutoActivationExtensions.Keyed.cs
來源:
AutoActivationExtensions.Keyed.cs

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

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

參數

services
IServiceCollection

要加入服務的服務集合。

serviceType
Type

要註冊的服務類型。

serviceKey
Object

用來唯一識別特定服務的物件。

implementationType
Type

服務的實作類型。

適用於

TryAddActivatedKeyedSingleton<TService,TImplementation>(IServiceCollection, Object)

來源:
AutoActivationExtensions.Keyed.cs
來源:
AutoActivationExtensions.Keyed.cs

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

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

類型參數

TService

要新增的服務類型。

TImplementation

要使用的實作類型。

參數

services
IServiceCollection

要加入服務的服務集合。

serviceKey
Object

用來唯一識別特定服務的物件。

適用於

TryAddActivatedKeyedSingleton<TService>(IServiceCollection, Object)

來源:
AutoActivationExtensions.Keyed.cs
來源:
AutoActivationExtensions.Keyed.cs

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

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

類型參數

TService

要新增的服務類型。

參數

services
IServiceCollection

要加入服務的服務集合。

serviceKey
Object

用來唯一識別特定服務的物件。

適用於

TryAddActivatedKeyedSingleton<TService>(IServiceCollection, Object, Func<IServiceProvider,Object,TService>)

來源:
AutoActivationExtensions.Keyed.cs
來源:
AutoActivationExtensions.Keyed.cs

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

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

類型參數

TService

要新增的服務類型。

參數

services
IServiceCollection

要加入服務的服務集合。

serviceKey
Object

用來唯一識別特定服務的物件。

implementationFactory
Func<IServiceProvider,Object,TService>

建立服務的 Factory。

適用於