ServiceCollectionDescriptorExtensions extension

Extension methods for adding and removing services to an ServiceCollection.

on

Methods

removeAll(Type serviceType) ServiceCollection

Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension

Removes all services of type serviceType 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 as descriptor and adds descriptor to the collection.
tryAdd(ServiceDescriptor descriptor) → void

Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension

Adds the specified descriptor 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 in services.
tryAddScoped<TService>(ImplementationFactory implementationFactory) → void

Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension

Adds the specified TService as a ServiceLifetime.scoped service using the factory specified in implementationFactory to the services if the service type hasn't already been registered.
tryAddSingleton<TService>(ImplementationFactory implementationFactory) → void

Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension

Adds the specified TService as a ServiceLifetime.singleton service using the factory specified in implementationFactory to the services 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 specified TService as a ServiceLifetime.transient service using the factory specified in implementationFactory to the services if the service type hasn't already been registered.