Microsoft.Extensions.DependencyInjection.Abstractions by Microsoft

<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0-preview.5.21301.5" />

 ServiceCollectionDescriptorExtensions

Extension methods for adding and removing services to an IServiceCollection.
public static IServiceCollection Add(this IServiceCollection collection, ServiceDescriptor descriptor)

Adds the specified descriptor to the collection.

public static IServiceCollection Add(this IServiceCollection collection, IEnumerable<ServiceDescriptor> descriptors)

Adds a sequence of ServiceDescriptor to the collection.

public static IServiceCollection RemoveAll<T>(this IServiceCollection collection)

Removes all services of type T in IServiceCollection.

public static IServiceCollection RemoveAll(this IServiceCollection collection, Type serviceType)

Removes all services of type serviceType in IServiceCollection.

public static IServiceCollection Replace(this IServiceCollection collection, ServiceDescriptor descriptor)

Removes the first service in IServiceCollection with the same service type as descriptor and adds descriptor to the collection.

public static void TryAdd(this IServiceCollection collection, ServiceDescriptor descriptor)

Adds the specified descriptor to the collection if the service type hasn't already been registered.

public static void TryAdd(this IServiceCollection collection, IEnumerable<ServiceDescriptor> descriptors)

Adds the specified descriptors to the collection if the service type hasn't already been registered.

public static void TryAddEnumerable(this IServiceCollection services, ServiceDescriptor descriptor)

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

public static void TryAddEnumerable(this IServiceCollection services, IEnumerable<ServiceDescriptor> descriptors)

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

public static void TryAddScoped(this IServiceCollection collection, Type service)

Adds the specified service as a Scoped service to the collection if the service type hasn't already been registered.

public static void TryAddScoped(this IServiceCollection collection, Type service, Type implementationType)

Adds the specified service as a Scoped service with the implementationType implementation to the collection if the service type hasn't already been registered.

public static void TryAddScoped(this IServiceCollection collection, Type service, Func<IServiceProvider, object> implementationFactory)

Adds the specified service as a Scoped service using the factory specified in implementationFactory to the collection if the service type hasn't already been registered.

public static void TryAddScoped<TService>(this IServiceCollection collection)

Adds the specified TService as a Scoped service to the collection if the service type hasn't already been registered.

public static void TryAddScoped<TService, TImplementation>(this IServiceCollection collection) where TImplementation : TService

Adds the specified TService as a Scoped service implementation type specified in TImplementation to the collection if the service type hasn't already been registered.

public static void TryAddScoped<TService>(this IServiceCollection services, Func<IServiceProvider, TService> implementationFactory)

Adds the specified TService as a Scoped service using the factory specified in implementationFactory to the services if the service type hasn't already been registered.

public static void TryAddSingleton(this IServiceCollection collection, Type service)

Adds the specified service as a Singleton service to the collection if the service type hasn't already been registered.

public static void TryAddSingleton(this IServiceCollection collection, Type service, Type implementationType)

Adds the specified service as a Singleton service with the implementationType implementation to the collection if the service type hasn't already been registered.

public static void TryAddSingleton(this IServiceCollection collection, Type service, Func<IServiceProvider, object> implementationFactory)

Adds the specified service as a Singleton service using the factory specified in implementationFactory to the collection if the service type hasn't already been registered.

public static void TryAddSingleton<TService>(this IServiceCollection collection)

Adds the specified TService as a Singleton service to the collection if the service type hasn't already been registered.

public static void TryAddSingleton<TService, TImplementation>(this IServiceCollection collection) where TImplementation : TService

Adds the specified TService as a Singleton service implementation type specified in TImplementation to the collection if the service type hasn't already been registered.

public static void TryAddSingleton<TService>(this IServiceCollection collection, TService instance)

Adds the specified TService as a Singleton service with an instance specified in instance to the collection if the service type hasn't already been registered.

public static void TryAddSingleton<TService>(this IServiceCollection services, Func<IServiceProvider, TService> implementationFactory)

Adds the specified TService as a Singleton service using the factory specified in implementationFactory to the services if the service type hasn't already been registered.

public static void TryAddTransient(this IServiceCollection collection, Type service)

Adds the specified service as a Transient service to the collection if the service type hasn't already been registered.

public static void TryAddTransient(this IServiceCollection collection, Type service, Type implementationType)

Adds the specified service as a Transient service with the implementationType implementation to the collection if the service type hasn't already been registered.

public static void TryAddTransient(this IServiceCollection collection, Type service, Func<IServiceProvider, object> implementationFactory)

Adds the specified service as a Transient service using the factory specified in implementationFactory to the collection if the service type hasn't already been registered.

public static void TryAddTransient<TService>(this IServiceCollection collection)

Adds the specified TService as a Transient service to the collection if the service type hasn't already been registered.

public static void TryAddTransient<TService, TImplementation>(this IServiceCollection collection) where TImplementation : TService

Adds the specified TService as a Transient service implementation type specified in TImplementation to the collection if the service type hasn't already been registered.

public static void TryAddTransient<TService>(this IServiceCollection services, Func<IServiceProvider, TService> implementationFactory)

Adds the specified TService as a Transient service using the factory specified in implementationFactory to the services if the service type hasn't already been registered.