ServiceCollectionDescriptorExtensions.TryAddEnumerable ServiceCollectionDescriptorExtensions.TryAddEnumerable ServiceCollectionDescriptorExtensions.TryAddEnumerable ServiceCollectionDescriptorExtensions.TryAddEnumerable Method

Definition

Overloads

TryAddEnumerable(IServiceCollection, ServiceDescriptor) TryAddEnumerable(IServiceCollection, ServiceDescriptor) TryAddEnumerable(IServiceCollection, ServiceDescriptor) TryAddEnumerable(IServiceCollection, ServiceDescriptor)

Adds a ServiceDescriptor if an existing descriptor with the same ServiceType and an implementation that does not already exist in services...

TryAddEnumerable(IServiceCollection, IEnumerable<ServiceDescriptor>) TryAddEnumerable(IServiceCollection, IEnumerable<ServiceDescriptor>) TryAddEnumerable(IServiceCollection, IEnumerable<ServiceDescriptor>) TryAddEnumerable(IServiceCollection, IEnumerable<ServiceDescriptor>)

Adds the specified ServiceDescriptors if an existing descriptor with the same ServiceType and an implementation that does not already exist in services...

TryAddEnumerable(IServiceCollection, ServiceDescriptor) TryAddEnumerable(IServiceCollection, ServiceDescriptor) TryAddEnumerable(IServiceCollection, ServiceDescriptor) TryAddEnumerable(IServiceCollection, ServiceDescriptor)

Adds a ServiceDescriptor if an existing descriptor with the same ServiceType and an implementation that does not already exist in services...

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)

Parameters

Remarks

Use TryAddEnumerable(IServiceCollection, ServiceDescriptor) when registering a service implementation of a service type that supports multiple registrations of the same service type. Using Add(IServiceCollection, ServiceDescriptor) is not idempotent and can add duplicate ServiceDescriptor instances if called twice. Using TryAddEnumerable(IServiceCollection, ServiceDescriptor) will prevent registration of multiple implementation types.

TryAddEnumerable(IServiceCollection, IEnumerable<ServiceDescriptor>) TryAddEnumerable(IServiceCollection, IEnumerable<ServiceDescriptor>) TryAddEnumerable(IServiceCollection, IEnumerable<ServiceDescriptor>) TryAddEnumerable(IServiceCollection, IEnumerable<ServiceDescriptor>)

Adds the specified ServiceDescriptors if an existing descriptor with the same ServiceType and an implementation that does not already exist in services...

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))

Parameters

Remarks

Use TryAddEnumerable(IServiceCollection, ServiceDescriptor) when registering a service implementation of a service type that supports multiple registrations of the same service type. Using Add(IServiceCollection, ServiceDescriptor) is not idempotent and can add duplicate ServiceDescriptor instances if called twice. Using TryAddEnumerable(IServiceCollection, ServiceDescriptor) will prevent registration of multiple implementation types.

Applies to