ServiceCollectionDescriptorExtensions.TryAddKeyedScoped 方法

定义

重载

名称 说明
TryAddKeyedScoped(IServiceCollection, Type, Object, Type)

将指定的 service 作为具有 Scoped 实现的 implementationType 服务添加到 collection(如果尚未注册服务类型)。

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

使用 service 中指定的工厂将指定的 Scoped 作为 implementationFactory 服务添加到 collection(如果尚未注册服务类型)。

TryAddKeyedScoped(IServiceCollection, Type, Object)

将指定的 service 作为 Scoped 服务添加到 collection(如果尚未注册服务类型)。

TryAddKeyedScoped<TService,TImplementation>(IServiceCollection, Object)

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

TryAddKeyedScoped<TService>(IServiceCollection, Object)

将指定的 TService 作为 Scoped 服务添加到 collection(如果尚未注册服务类型)。

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

使用 TService 中指定的工厂将指定的 Scoped 作为 implementationFactory 服务添加到 services(如果尚未注册服务类型)。

TryAddKeyedScoped(IServiceCollection, Type, Object, Type)

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

将指定的 service 作为具有 Scoped 实现的 implementationType 服务添加到 collection(如果尚未注册服务类型)。

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

参数

service
Type

要注册的服务的类型。

serviceKey
Object

服务密钥。

implementationType
Type

服务的实现类型。

另请参阅

适用于

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

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

使用 service 中指定的工厂将指定的 Scoped 作为 implementationFactory 服务添加到 collection(如果尚未注册服务类型)。

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

创建服务的工厂。

另请参阅

适用于

TryAddKeyedScoped(IServiceCollection, Type, Object)

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

将指定的 service 作为 Scoped 服务添加到 collection(如果尚未注册服务类型)。

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

参数

service
Type

要注册的服务的类型。

serviceKey
Object

服务密钥。

另请参阅

适用于

TryAddKeyedScoped<TService,TImplementation>(IServiceCollection, Object)

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

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

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

类型参数

TService

要添加的服务的类型。

TImplementation

要使用的实现的类型。

参数

serviceKey
Object

服务密钥。

另请参阅

适用于

TryAddKeyedScoped<TService>(IServiceCollection, Object)

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

将指定的 TService 作为 Scoped 服务添加到 collection(如果尚未注册服务类型)。

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

类型参数

TService

要添加的服务的类型。

参数

serviceKey
Object

服务密钥。

另请参阅

适用于

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

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

使用 TService 中指定的工厂将指定的 Scoped 作为 implementationFactory 服务添加到 services(如果尚未注册服务类型)。

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

创建服务的工厂。

另请参阅

适用于