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.
Removes all services of type T in IServiceCollection.
Removes all services of type serviceType in IServiceCollection.
public static IServiceCollection RemoveAllKeyed<T>(this IServiceCollection collection, object serviceKey)
Removes all services of type T in collection.
public static IServiceCollection RemoveAllKeyed(this IServiceCollection collection, Type serviceType, object serviceKey)
Removes all services of type serviceType in collection.
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.
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.
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 TryAddKeyedScoped(this IServiceCollection collection, Type service, object serviceKey)
Adds the specified service as a Scoped service to the collection if the service type hasn't already been registered.
public static void TryAddKeyedScoped(this IServiceCollection collection, Type service, object serviceKey, 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 TryAddKeyedScoped(this IServiceCollection collection, Type service, object serviceKey, Func<IServiceProvider, object, 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 TryAddKeyedScoped<TService>(this IServiceCollection collection, object serviceKey)
Adds the specified TService as a Scoped service to the collection if the service type hasn't already been registered.
public static void TryAddKeyedScoped<TService, TImplementation>(this IServiceCollection collection, object serviceKey) 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 TryAddKeyedScoped<TService>(this IServiceCollection services, object serviceKey, Func<IServiceProvider, object, 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 TryAddKeyedSingleton(this IServiceCollection collection, Type service, object serviceKey)
Adds the specified service as a Singleton service to the collection if the service type hasn't already been registered.
public static void TryAddKeyedSingleton(this IServiceCollection collection, Type service, object serviceKey, 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 TryAddKeyedSingleton(this IServiceCollection collection, Type service, object serviceKey, Func<IServiceProvider, object, 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 TryAddKeyedSingleton<TService>(this IServiceCollection collection, object serviceKey)
Adds the specified TService as a Singleton service to the collection if the service type hasn't already been registered.
public static void TryAddKeyedSingleton<TService, TImplementation>(this IServiceCollection collection, object serviceKey) 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 TryAddKeyedSingleton<TService>(this IServiceCollection collection, object serviceKey, 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 TryAddKeyedSingleton<TService>(this IServiceCollection services, object serviceKey, Func<IServiceProvider, object, 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 TryAddKeyedTransient(this IServiceCollection collection, Type service, object serviceKey)
Adds the specified service as a Transient service to the collection if the service type hasn't already been registered.
public static void TryAddKeyedTransient(this IServiceCollection collection, Type service, object serviceKey, 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 TryAddKeyedTransient(this IServiceCollection collection, Type service, object serviceKey, Func<IServiceProvider, object, 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 TryAddKeyedTransient<TService>(this IServiceCollection collection, object serviceKey)
Adds the specified TService as a Transient service to the collection if the service type hasn't already been registered.
public static void TryAddKeyedTransient<TService, TImplementation>(this IServiceCollection collection, object serviceKey) 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 TryAddKeyedTransient<TService>(this IServiceCollection services, object serviceKey, Func<IServiceProvider, object, 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.
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.
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.
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.
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.
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.
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.
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.