Share via


IServiceCollection Interface

Definition

Specifies the contract for a collection of service descriptors.

public interface class IServiceCollection : System::Collections::Generic::ICollection<Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^>, System::Collections::Generic::IEnumerable<Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^>, System::Collections::Generic::IList<Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^>
public interface IServiceCollection : System.Collections.Generic.ICollection<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>, System.Collections.Generic.IEnumerable<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>, System.Collections.Generic.IList<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>
type IServiceCollection = interface
    interface IList<ServiceDescriptor>
    interface ICollection<ServiceDescriptor>
    interface seq<ServiceDescriptor>
    interface IEnumerable
Public Interface IServiceCollection
Implements ICollection(Of ServiceDescriptor), IEnumerable(Of ServiceDescriptor), IList(Of ServiceDescriptor)
Derived
Implements

Properties

Count

Gets the number of elements contained in the ICollection<T>.

(Inherited from ICollection<T>)
IsReadOnly

Gets a value indicating whether the ICollection<T> is read-only.

(Inherited from ICollection<T>)
Item[Int32]

Gets or sets the element at the specified index.

(Inherited from IList<T>)

Methods

Add(T)

Adds an item to the ICollection<T>.

(Inherited from ICollection<T>)
Clear()

Removes all items from the ICollection<T>.

(Inherited from ICollection<T>)
Contains(T)

Determines whether the ICollection<T> contains a specific value.

(Inherited from ICollection<T>)
CopyTo(T[], Int32)

Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.

(Inherited from ICollection<T>)
GetEnumerator()

Returns an enumerator that iterates through a collection.

(Inherited from IEnumerable)
IndexOf(T)

Determines the index of a specific item in the IList<T>.

(Inherited from IList<T>)
Insert(Int32, T)

Inserts an item to the IList<T> at the specified index.

(Inherited from IList<T>)
Remove(T)

Removes the first occurrence of a specific object from the ICollection<T>.

(Inherited from ICollection<T>)
RemoveAt(Int32)

Removes the IList<T> item at the specified index.

(Inherited from IList<T>)

Extension Methods

AddServiceLogEnricher(IServiceCollection, IConfigurationSection)

Adds an instance of the service enricher to the IServiceCollection.

AddServiceLogEnricher(IServiceCollection, Action<ApplicationLogEnricherOptions>)

Adds an instance of the service enricher to the IServiceCollection.

AddServiceLogEnricher(IServiceCollection)

Adds an instance of the service enricher to the IServiceCollection.

AddApplicationMetadata(IServiceCollection, IConfigurationSection)

Adds an instance of ApplicationMetadata to a dependency injection container.

AddApplicationMetadata(IServiceCollection, Action<ApplicationMetadata>)

Adds an instance of ApplicationMetadata to a dependency injection container.

AddAsyncState(IServiceCollection)

Adds default implementations for IAsyncState, IAsyncContext<T>, and Microsoft.Extensions.AsyncState.IAsyncLocalContext`1 services. Please note that implementations of these interfaces are not thread safe.

ActivateKeyedSingleton(IServiceCollection, Type, Object)

Enforces keyed singleton activation at startup time rather than at runtime.

ActivateKeyedSingleton<TService>(IServiceCollection, Object)

Enforces keyed singleton activation at startup time rather than at runtime.

ActivateSingleton(IServiceCollection, Type)

Enforces singleton activation at startup time rather than at runtime.

ActivateSingleton<TService>(IServiceCollection)

Enforces singleton activation at startup time rather than at runtime.

AddActivatedKeyedSingleton(IServiceCollection, Type, Object, Func<IServiceProvider,Object,Object>)

Adds an auto-activated keyed singleton service.

AddActivatedKeyedSingleton(IServiceCollection, Type, Object, Type)

Adds an auto-activated keyed singleton service.

AddActivatedKeyedSingleton(IServiceCollection, Type, Object)

Adds an auto-activated keyed singleton service.

AddActivatedKeyedSingleton<TService>(IServiceCollection, Object, Func<IServiceProvider,Object,TService>)

Adds an auto-activated keyed singleton service.

AddActivatedKeyedSingleton<TService>(IServiceCollection, Object)

Adds an auto-activated keyed singleton service.

AddActivatedKeyedSingleton<TService,TImplementation>(IServiceCollection, Object, Func<IServiceProvider,Object,TImplementation>)

Adds an auto-activated keyed singleton service.

AddActivatedKeyedSingleton<TService,TImplementation>(IServiceCollection, Object)

Adds an auto-activated keyed singleton service.

AddActivatedSingleton(IServiceCollection, Type, Func<IServiceProvider,Object>)

Adds an auto-activated singleton service.

AddActivatedSingleton(IServiceCollection, Type, Type)

Adds an auto-activated singleton service.

AddActivatedSingleton(IServiceCollection, Type)

Adds an auto-activated singleton service of the type specified in serviceType to the specified IServiceCollection.

AddActivatedSingleton<TService>(IServiceCollection, Func<IServiceProvider,TService>)

Adds an auto-activated singleton service.

AddActivatedSingleton<TService>(IServiceCollection)

Adds an auto-activated singleton service.

AddActivatedSingleton<TService,TImplementation>(IServiceCollection, Func<IServiceProvider,TImplementation>)

Adds an auto-activated singleton service.

AddActivatedSingleton<TService,TImplementation>(IServiceCollection)

Adds an auto-activated singleton service.

TryAddActivatedKeyedSingleton(IServiceCollection, Type, Object, Func<IServiceProvider,Object,Object>)

Tries to add an auto-activated keyed singleton service.

TryAddActivatedKeyedSingleton(IServiceCollection, Type, Object, Type)

Tries to add an auto-activated keyed singleton service.

TryAddActivatedKeyedSingleton(IServiceCollection, Type, Object)

Tries to add an auto-activated keyed singleton service.

TryAddActivatedKeyedSingleton<TService>(IServiceCollection, Object, Func<IServiceProvider,Object,TService>)

Tries to add an auto-activated keyed singleton service.

TryAddActivatedKeyedSingleton<TService>(IServiceCollection, Object)

Tries to add an auto-activated keyed singleton service.

TryAddActivatedKeyedSingleton<TService,TImplementation>(IServiceCollection, Object)

Tries to add an auto-activated keyed singleton service.

TryAddActivatedSingleton(IServiceCollection, Type, Func<IServiceProvider,Object>)

Tries to add an auto-activated singleton service.

TryAddActivatedSingleton(IServiceCollection, Type, Type)

Tries to add an auto-activated singleton service.

TryAddActivatedSingleton(IServiceCollection, Type)

Tries to add an auto-activated singleton service.

TryAddActivatedSingleton<TService>(IServiceCollection, Func<IServiceProvider,TService>)

Tries to add an auto-activated singleton service.

TryAddActivatedSingleton<TService>(IServiceCollection)

Tries to add an auto-activated singleton service.

TryAddActivatedSingleton<TService,TImplementation>(IServiceCollection)

Tries to add an auto-activated singleton service.

AddChatClient(IServiceCollection, IChatClient, ServiceLifetime)

Registers a singleton IChatClient in the IServiceCollection.

AddChatClient(IServiceCollection, Func<IServiceProvider,IChatClient>, ServiceLifetime)

Registers a singleton IChatClient in the IServiceCollection.

AddKeyedChatClient(IServiceCollection, Object, IChatClient, ServiceLifetime)

Registers a keyed singleton IChatClient in the IServiceCollection.

AddKeyedChatClient(IServiceCollection, Object, Func<IServiceProvider,IChatClient>, ServiceLifetime)

Registers a keyed singleton IChatClient in the IServiceCollection.

AddTelemetryHealthCheckPublisher(IServiceCollection, IConfigurationSection)

Registers a health check publisher which emits telemetry representing the application's health.

AddTelemetryHealthCheckPublisher(IServiceCollection, Action<TelemetryHealthCheckPublisherOptions>)

Registers a health check publisher which emits telemetry representing the application's health.

AddTelemetryHealthCheckPublisher(IServiceCollection)

Registers a health check publisher which emits telemetry representing the application's health.

AddContextualOptions(IServiceCollection)

Adds services required for using contextual options.

Configure<TOptions>(IServiceCollection, Action<IOptionsContext,TOptions>)

Registers an action used to configure a particular type of options.

Configure<TOptions>(IServiceCollection, Func<IOptionsContext,CancellationToken,ValueTask<IConfigureContextualOptions<TOptions>>>)

Registers an action used to configure a particular type of options.

Configure<TOptions>(IServiceCollection, String, Action<IOptionsContext,TOptions>)

Registers an action used to configure a particular type of options.

Configure<TOptions>(IServiceCollection, String, Func<IOptionsContext,CancellationToken,ValueTask<IConfigureContextualOptions<TOptions>>>)

Registers an action used to configure a particular type of options.

ConfigureAll<TOptions>(IServiceCollection, Action<IOptionsContext,TOptions>)

Registers an action used to configure all instances of a particular type of options.

ConfigureAll<TOptions>(IServiceCollection, Func<IOptionsContext,CancellationToken,ValueTask<IConfigureContextualOptions<TOptions>>>)

Registers an action used to configure all instances of a particular type of options.

AddEmbeddingGenerator<TInput,TEmbedding>(IServiceCollection, IEmbeddingGenerator<TInput,TEmbedding>, ServiceLifetime)

Registers a singleton embedding generator in the IServiceCollection.

AddEmbeddingGenerator<TInput,TEmbedding>(IServiceCollection, Func<IServiceProvider,IEmbeddingGenerator<TInput,TEmbedding>>, ServiceLifetime)

Registers a singleton embedding generator in the IServiceCollection.

AddKeyedEmbeddingGenerator<TInput,TEmbedding>(IServiceCollection, Object, IEmbeddingGenerator<TInput,TEmbedding>, ServiceLifetime)

Registers a keyed singleton embedding generator in the IServiceCollection.

AddKeyedEmbeddingGenerator<TInput,TEmbedding>(IServiceCollection, Object, Func<IServiceProvider,IEmbeddingGenerator<TInput,TEmbedding>>, ServiceLifetime)

Registers a keyed singleton embedding generator in the IServiceCollection.

AddWebEncoders(IServiceCollection, Action<WebEncoderOptions>)

Adds HtmlEncoder, JavaScriptEncoder and UrlEncoder to the specified services.

AddWebEncoders(IServiceCollection)

Adds HtmlEncoder, JavaScriptEncoder and UrlEncoder to the specified services.

AddLogEnricher(IServiceCollection, ILogEnricher)

Registers a log enricher instance.

AddLogEnricher<T>(IServiceCollection)

Registers a log enricher type.

AddStaticLogEnricher(IServiceCollection, IStaticLogEnricher)

Registers a static log enricher instance.

AddStaticLogEnricher<T>(IServiceCollection)

Registers a static log enricher type.

AddExceptionSummarizer(IServiceCollection, Action<IExceptionSummarizationBuilder>)

Registers an exception summarizer into a dependency injection container.

AddExceptionSummarizer(IServiceCollection)

Registers an exception summarizer into a dependency injection container.

Add(IServiceCollection, ServiceDescriptor)

Adds the specified descriptor to the collection.

Add(IServiceCollection, IEnumerable<ServiceDescriptor>)

Adds a sequence of ServiceDescriptor to the collection.

RemoveAll(IServiceCollection, Type)

Removes all services of type serviceType in IServiceCollection.

RemoveAll<T>(IServiceCollection)

Removes all services of type T in IServiceCollection.

RemoveAllKeyed(IServiceCollection, Type, Object)

Removes all services of type serviceType in IServiceCollection.

RemoveAllKeyed<T>(IServiceCollection, Object)

Removes all services of type T in IServiceCollection.

Replace(IServiceCollection, ServiceDescriptor)

Removes the first service in IServiceCollection with the same service type as descriptor and adds descriptor to the collection.

TryAdd(IServiceCollection, ServiceDescriptor)

Adds the specified descriptor to the collection if the service type hasn't already been registered.

TryAdd(IServiceCollection, IEnumerable<ServiceDescriptor>)

Adds the specified descriptors to the collection if the service type hasn't already been registered.

TryAddEnumerable(IServiceCollection, ServiceDescriptor)

Adds a ServiceDescriptor if an existing descriptor with the same ServiceType and an implementation that does not already exist in services.

TryAddEnumerable(IServiceCollection, IEnumerable<ServiceDescriptor>)

Adds the specified ServiceDescriptors if an existing descriptor with the same ServiceType and an implementation that does not already exist in services.

TryAddKeyedScoped(IServiceCollection, Type, Object, Func<IServiceProvider,Object,Object>)

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.

TryAddKeyedScoped(IServiceCollection, Type, Object, Type)

Adds the specified service as a Scoped service with the implementationType implementation to the collection if the service type hasn't already been registered.

TryAddKeyedScoped(IServiceCollection, Type, Object)

Adds the specified service as a Scoped service to the collection if the service type hasn't already been registered.

TryAddKeyedScoped<TService>(IServiceCollection, Object, Func<IServiceProvider,Object,TService>)

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.

TryAddKeyedScoped<TService>(IServiceCollection, Object)

Adds the specified TService as a Scoped service to the collection if the service type hasn't already been registered.

TryAddKeyedScoped<TService,TImplementation>(IServiceCollection, Object)

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.

TryAddKeyedSingleton(IServiceCollection, Type, Object, Func<IServiceProvider,Object,Object>)

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.

TryAddKeyedSingleton(IServiceCollection, Type, Object, Type)

Adds the specified service as a Singleton service with the implementationType implementation to the collection if the service type hasn't already been registered.

TryAddKeyedSingleton(IServiceCollection, Type, Object)

Adds the specified service as a Singleton service to the collection if the service type hasn't already been registered.