AutoActivationExtensions.AddActivatedKeyedSingleton 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
AddActivatedKeyedSingleton(IServiceCollection, Type, Object)
新增自動啟用的金鑰單一服務。
public:
[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddActivatedKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Type ^ serviceType, System::Object ^ serviceKey);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddActivatedKeyedSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType, object? serviceKey);
static member AddActivatedKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * obj -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddActivatedKeyedSingleton (services As IServiceCollection, serviceType As Type, serviceKey As Object) As IServiceCollection
參數
- services
- IServiceCollection
要加入服務的服務集合。
- serviceType
- Type
要註冊的服務類型,以及要使用的實作。
- serviceKey
- Object
用來唯一識別特定服務的物件。
傳回
services
的值。
適用於
AddActivatedKeyedSingleton(IServiceCollection, Type, Object, Func<IServiceProvider,Object,Object>)
新增自動啟用的金鑰單一服務。
public:
[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddActivatedKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Type ^ serviceType, System::Object ^ serviceKey, Func<IServiceProvider ^, System::Object ^, System::Object ^> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddActivatedKeyedSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType, object? serviceKey, Func<IServiceProvider,object?,object> implementationFactory);
static member AddActivatedKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * obj * Func<IServiceProvider, obj, obj> -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddActivatedKeyedSingleton (services As IServiceCollection, serviceType As Type, serviceKey As Object, implementationFactory As Func(Of IServiceProvider, Object, Object)) As IServiceCollection
參數
- services
- IServiceCollection
要加入服務的服務集合。
- serviceType
- Type
要註冊的服務類型。
- serviceKey
- Object
用來唯一識別特定服務的物件。
- implementationFactory
- Func<IServiceProvider,Object,Object>
建立服務的 Factory。
傳回
services
的值。
適用於
AddActivatedKeyedSingleton(IServiceCollection, Type, Object, Type)
新增自動啟用的金鑰單一服務。
public:
[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddActivatedKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Type ^ serviceType, System::Object ^ serviceKey, Type ^ implementationType);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddActivatedKeyedSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType, object? serviceKey, Type implementationType);
static member AddActivatedKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * obj * Type -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddActivatedKeyedSingleton (services As IServiceCollection, serviceType As Type, serviceKey As Object, implementationType As Type) As IServiceCollection
參數
- services
- IServiceCollection
要加入服務的服務集合。
- serviceType
- Type
要註冊的服務類型。
- serviceKey
- Object
用來唯一識別特定服務的物件。
- implementationType
- Type
服務的實作類型。
傳回
services
的值。
適用於
AddActivatedKeyedSingleton<TService,TImplementation>(IServiceCollection, Object)
新增自動啟用的金鑰單一服務。
public:
generic <typename TService, typename TImplementation>
where TService : class where TImplementation : class, TService[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddActivatedKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::Object ^ serviceKey);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddActivatedKeyedSingleton<TService,TImplementation> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, object? serviceKey) where TService : class where TImplementation : class, TService;
static member AddActivatedKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddActivatedKeyedSingleton(Of TService As Class, TImplementation As Class) (services As IServiceCollection, serviceKey As Object) As IServiceCollection
類型參數
- TService
要新增的服務類型。
- TImplementation
要使用的實作類型。
參數
- services
- IServiceCollection
要加入服務的服務集合。
- serviceKey
- Object
用來唯一識別特定服務的物件。
傳回
services
的值。
適用於
AddActivatedKeyedSingleton<TService,TImplementation>(IServiceCollection, Object, Func<IServiceProvider,Object,TImplementation>)
新增自動啟用的金鑰單一服務。
public:
generic <typename TService, typename TImplementation>
where TService : class where TImplementation : class, TService[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddActivatedKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::Object ^ serviceKey, Func<IServiceProvider ^, System::Object ^, TImplementation> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddActivatedKeyedSingleton<TService,TImplementation> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, object? serviceKey, Func<IServiceProvider,object?,TImplementation> implementationFactory) where TService : class where TImplementation : class, TService;
static member AddActivatedKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj * Func<IServiceProvider, obj, #'Service> -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddActivatedKeyedSingleton(Of TService As Class, TImplementation As Class) (services As IServiceCollection, serviceKey As Object, implementationFactory As Func(Of IServiceProvider, Object, TImplementation)) As IServiceCollection
類型參數
- TService
要新增的服務類型。
- TImplementation
要使用的實作類型。
參數
- services
- IServiceCollection
要加入服務的服務集合。
- serviceKey
- Object
用來唯一識別特定服務的物件。
- implementationFactory
- Func<IServiceProvider,Object,TImplementation>
建立服務的 Factory。
傳回
services
的值。
適用於
AddActivatedKeyedSingleton<TService>(IServiceCollection, Object)
新增自動啟用的金鑰單一服務。
public:
generic <typename TService>
where TService : class[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddActivatedKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::Object ^ serviceKey);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddActivatedKeyedSingleton<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, object? serviceKey) where TService : class;
static member AddActivatedKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddActivatedKeyedSingleton(Of TService As Class) (services As IServiceCollection, serviceKey As Object) As IServiceCollection
類型參數
- TService
要新增的服務類型。
參數
- services
- IServiceCollection
要加入服務的服務集合。
- serviceKey
- Object
用來唯一識別特定服務的物件。
傳回
services
的值。
適用於
AddActivatedKeyedSingleton<TService>(IServiceCollection, Object, Func<IServiceProvider,Object,TService>)
新增自動啟用的金鑰單一服務。
public:
generic <typename TService>
where TService : class[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddActivatedKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::Object ^ serviceKey, Func<IServiceProvider ^, System::Object ^, TService> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddActivatedKeyedSingleton<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, object? serviceKey, Func<IServiceProvider,object?,TService> implementationFactory) where TService : class;
static member AddActivatedKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj * Func<IServiceProvider, obj, 'Service (requires 'Service : null)> -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddActivatedKeyedSingleton(Of TService As Class) (services As IServiceCollection, serviceKey As Object, implementationFactory As Func(Of IServiceProvider, Object, TService)) As IServiceCollection
類型參數
- TService
要新增的服務類型。
參數
- services
- IServiceCollection
要加入服務的服務集合。
- serviceKey
- Object
用來唯一識別特定服務的物件。
- implementationFactory
- Func<IServiceProvider,Object,TService>
建立服務的 Factory。
傳回
services
的值。