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.
removeAllKeyed(Type serviceType, Object? serviceKey) 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.
tryAddKeyedScoped<TService>(Object? serviceKey, KeyedImplementationFactory implementationFactory) → void

Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension

tryAddKeyedSingleton<TService>(Object? serviceKey, KeyedImplementationFactory implementationFactory) → void

Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension

Adds the specified TService as a ServiceLifetime.singleton service with the specified serviceKey using the factory specified in implementationFactory to the services if the service type hasn't already been registered with that key.
tryAddKeyedSingletonInstance<TService>(Object? serviceKey, Object implementationInstance) → void

Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension

tryAddKeyedTransient<TService>(Object? serviceKey, KeyedImplementationFactory implementationFactory) → void

Available on ServiceCollection, provided by the ServiceCollectionDescriptorExtensions extension

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.