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 typeserviceType
in ServiceCollection. -
replace(
ServiceDescriptor descriptor) → ServiceCollection -
Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension
Removes the first service in ServiceCollection with the same service type asdescriptor
and addsdescriptor
to the collection. -
tryAdd(
ServiceDescriptor descriptor) → void -
Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension
Adds the specifieddescriptor
to 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 specifiedTService
as a ServiceLifetime.scoped service using the factory specified inimplementationFactory
to theservices
if the service type hasn't already been registered. -
tryAddSingleton<
TService> (ImplementationFactory implementationFactory) → void -
Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension
Adds the specifiedTService
as a ServiceLifetime.singleton service using the factory specified inimplementationFactory
to theservices
if 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 specifiedTService
as a ServiceLifetime.transient service using the factory specified inimplementationFactory
to theservices
if the service type hasn't already been registered.