ServiceCollectionDescriptorExtensions.TryAddEnumerable 方法

定义

重载

TryAddEnumerable(IServiceCollection, ServiceDescriptor)

如果具有相同 ServiceType 的现有描述符和 services..中尚不存在的实现,则添加 ServiceDescriptor

TryAddEnumerable(IServiceCollection, IEnumerable<ServiceDescriptor>)

如果具有相同 ServiceType 的现有描述符和 services..中尚不存在的实现,则添加指定的 ServiceDescriptor

TryAddEnumerable(IServiceCollection, ServiceDescriptor)

Source:
ServiceCollectionDescriptorExtensions.cs
Source:
ServiceCollectionDescriptorExtensions.cs

如果具有相同 ServiceType 的现有描述符和 services..中尚不存在的实现,则添加 ServiceDescriptor

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

参数

注解

注册支持同一服务类型的多个注册的服务类型的服务实现时,请使用 TryAddEnumerable(IServiceCollection, ServiceDescriptor)。 使用 Add(IServiceCollection, ServiceDescriptor) 不是幂等的,如果调用两次,则可以添加重复 ServiceDescriptor 实例。 使用 TryAddEnumerable(IServiceCollection, ServiceDescriptor) 将阻止注册多个实现类型。

适用于

TryAddEnumerable(IServiceCollection, IEnumerable<ServiceDescriptor>)

Source:
ServiceCollectionDescriptorExtensions.cs
Source:
ServiceCollectionDescriptorExtensions.cs

如果具有相同 ServiceType 的现有描述符和 services..中尚不存在的实现,则添加指定的 ServiceDescriptor

public:
[System::Runtime::CompilerServices::Extension]
 static void TryAddEnumerable(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::Collections::Generic::IEnumerable<Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^> ^ descriptors);
public static void TryAddEnumerable (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Collections.Generic.IEnumerable<Microsoft.Extensions.DependencyInjection.ServiceDescriptor> descriptors);
static member TryAddEnumerable : Microsoft.Extensions.DependencyInjection.IServiceCollection * seq<Microsoft.Extensions.DependencyInjection.ServiceDescriptor> -> unit
<Extension()>
Public Sub TryAddEnumerable (services As IServiceCollection, descriptors As IEnumerable(Of ServiceDescriptor))

参数

注解

注册支持同一服务类型的多个注册的服务类型的服务实现时,请使用 TryAddEnumerable(IServiceCollection, ServiceDescriptor)。 使用 Add(IServiceCollection, ServiceDescriptor) 不是幂等的,如果调用两次,则可以添加重复 ServiceDescriptor 实例。 使用 TryAddEnumerable(IServiceCollection, ServiceDescriptor) 将阻止注册多个实现类型。

适用于