ServiceCollectionDescriptorExtensions extension
Extension methods for adding and removing services to an ServiceCollection.
Methods
-
removeAll(
Type serviceType) → ServiceCollection -
Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension
Removes all services of typeserviceTypein ServiceCollection. -
replace(
ServiceDescriptor descriptor) → ServiceCollection -
Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension
Removes the first service in ServiceCollection with the same service type asdescriptorand addsdescriptorto the collection. -
tryAdd(
ServiceDescriptor descriptor) → void -
Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension
Adds the specifieddescriptorto the list if the service type hasn't already been registered. -
tryAddIterable(
ServiceDescriptor descriptor) → void -
Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension
Adds a ServiceDescriptor if an existing descriptor with the same ServiceDescriptor.serviceType and an implementation that does not already exist inservices. -
tryAddScoped<
TService> (ImplementationFactory implementationFactory) → void -
Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension
Adds the specifiedTServiceas a ServiceLifetime.scoped service using the factory specified inimplementationFactoryto theservicesif the service type hasn't already been registered. -
tryAddSingleton<
TService> (ImplementationFactory implementationFactory) → void -
Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension
Adds the specifiedTServiceas a ServiceLifetime.singleton service using the factory specified inimplementationFactoryto theservicesif the service type hasn't already been registered. -
tryAddSingletonInstance<
TService> (Object implementationInstance) → void -
Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension
-
tryAddTransient<
TService> (ImplementationFactory implementationFactory) → void -
Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension
Adds the specifiedTServiceas a ServiceLifetime.transient service using the factory specified inimplementationFactoryto theservicesif the service type hasn't already been registered.