ServiceCollectionDescriptorExtensions.TryAddKeyedTransient 方法

定义

重载

TryAddKeyedTransient(IServiceCollection, Type, Object, Type)

如果服务类型尚未注册,则使用 implementationType 实现将指定的 service 作为 Transient 服务添加到 collection 中。

TryAddKeyedTransient(IServiceCollection, Type, Object)

如果服务类型尚未注册,则将指定的 service 作为 Transient 服务添加到 collection 中。

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

如果服务类型尚未注册,则使用 implementationFactory 中指定的中心将指定的 service 作为 Transient 服务添加到 collection 中。

TryAddKeyedTransient<TService,TImplementation>(IServiceCollection, Object)

如果服务类型尚未注册,则将指定的 TService 作为 TImplementation 中指定的 Transient 服务实现类型添加到 collection 中。

TryAddKeyedTransient<TService>(IServiceCollection, Object)

如果服务类型尚未注册,则将指定的 TService 作为 Transient 服务添加到 collection 中。

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

如果服务类型尚未注册,则使用 implementationFactory 中指定的中心将指定的 TService 作为 Transient 服务添加到 services 中。

TryAddKeyedTransient(IServiceCollection, Type, Object, Type)

Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs

如果服务类型尚未注册,则使用 implementationType 实现将指定的 service 作为 Transient 服务添加到 collection 中。

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

参数

service
Type

要注册的服务类型。

serviceKey
Object

服务密钥。

implementationType
Type

服务的实现类型。

适用于

TryAddKeyedTransient(IServiceCollection, Type, Object)

Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs

如果服务类型尚未注册,则将指定的 service 作为 Transient 服务添加到 collection 中。

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

参数

service
Type

要注册的服务类型。

serviceKey
Object

服务密钥。

适用于

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

Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs

如果服务类型尚未注册,则使用 implementationFactory 中指定的中心将指定的 service 作为 Transient 服务添加到 collection 中。

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

参数

service
Type

要注册的服务类型。

serviceKey
Object

服务密钥。

implementationFactory
Func<IServiceProvider,Object,Object>

用于创建服务的工厂。

适用于

TryAddKeyedTransient<TService,TImplementation>(IServiceCollection, Object)

Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs

如果服务类型尚未注册,则将指定的 TService 作为 TImplementation 中指定的 Transient 服务实现类型添加到 collection 中。

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

类型参数

TService

要添加的服务类型。

TImplementation

要使用的实现的类型。

参数

serviceKey
Object

服务密钥。

适用于

TryAddKeyedTransient<TService>(IServiceCollection, Object)

Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs

如果服务类型尚未注册,则将指定的 TService 作为 Transient 服务添加到 collection 中。

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

类型参数

TService

要添加的服务类型。

参数

serviceKey
Object

服务密钥。

适用于

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

Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs
Source:
ServiceCollectionDescriptorExtensions.Keyed.cs

如果服务类型尚未注册,则使用 implementationFactory 中指定的中心将指定的 TService 作为 Transient 服务添加到 services 中。

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

类型参数

TService

要添加的服务类型。

参数

serviceKey
Object

服务密钥。

implementationFactory
Func<IServiceProvider,Object,TService>

用于创建服务的工厂。

适用于