Delen via


ServiceCollectionMap Class

Definition

Provides a map over a IServiceCollection that allows ServiceDescriptor entries to be conditionally added or re-written without requiring linear scans of the service collection each time this is done.

public class ServiceCollectionMap : Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.Internal.InternalServiceCollectionMap>
public class ServiceCollectionMap : Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.Infrastructure.IInternalServiceCollectionMap>
type ServiceCollectionMap = class
    interface IInfrastructure<InternalServiceCollectionMap>
type ServiceCollectionMap = class
    interface IInfrastructure<IInternalServiceCollectionMap>
Public Class ServiceCollectionMap
Implements IInfrastructure(Of InternalServiceCollectionMap)
Public Class ServiceCollectionMap
Implements IInfrastructure(Of IInternalServiceCollectionMap)
Inheritance
ServiceCollectionMap
Implements
IInfrastructure<Microsoft.EntityFrameworkCore.Internal.InternalServiceCollectionMap> IInfrastructure<IInternalServiceCollectionMap>

Remarks

Note that the collection should not be modified without in other ways while it is being managed by the map. The collection can be used in the normal way after modifications using the map have been completed.

See Implementation of database providers and extensions for more information and examples.

Constructors

ServiceCollectionMap(IServiceCollection)

Creates a new ServiceCollectionMap to operate on the given IServiceCollection.

Properties

ServiceCollection

The underlying IServiceCollection.

Methods

TryAdd(Type, Func<IServiceProvider,Object>, ServiceLifetime)

Adds a service implemented by the given factory if no service for the given service type has already been registered.

TryAdd(Type, Type, ServiceLifetime)

Adds a service implemented by the given concrete type if no service for the given service type has already been registered.

TryAddEnumerable(Type, Type, Func<IServiceProvider,Object>, ServiceLifetime)

Adds a service implemented by the given factory to the list of services that implement the given contract. The service is only added if the collection contains no other registration for the same service and implementation type.

TryAddEnumerable(Type, Type, ServiceLifetime)

Adds a service implemented by the given concrete type to the list of services that implement the given contract. The service is only added if the collection contains no other registration for the same service and implementation type.

TryAddScoped(Type, Func<IServiceProvider,Object>)

Adds a Scoped service implemented by the given factory if no service for the given service type has already been registered.

TryAddScoped(Type, Type)

Adds a Scoped service implemented by the given concrete type if no service for the given service type has already been registered.

TryAddScoped<TService,TImplementation>()

Adds a Scoped service implemented by the given concrete type if no service for the given service type has already been registered.

TryAddScoped<TService,TImplementation>(Func<IServiceProvider,TImplementation>)

Adds a Scoped service implemented by the given factory if no service for the given service type has already been registered.

TryAddScoped<TService>(Func<IServiceProvider,TService>)

Adds a Scoped service implemented by the given factory if no service for the given service type has already been registered.

TryAddScopedEnumerable(Type, Type)

Adds a Scoped service implemented by the given concrete type to the list of services that implement the given contract. The service is only added if the collection contains no other registration for the same service and implementation type.

TryAddScopedEnumerable<TService,TImplementation>()

Adds a Scoped service implemented by the given concrete type to the list of services that implement the given contract. The service is only added if the collection contains no other registration for the same service and implementation type.

TryAddScopedEnumerable<TService,TImplementation>(Func<IServiceProvider,TImplementation>)

Adds a Scoped service implemented by the given factory to the list of services that implement the given contract. The service is only added if the collection contains no other registration for the same service and implementation type.

TryAddSingleton(Type, Func<IServiceProvider,Object>)

Adds a Singleton service implemented by the given factory if no service for the given service type has already been registered.

TryAddSingleton(Type, Object)

Adds a Singleton service implemented by the given instance if no service for the given service type has already been registered.

TryAddSingleton(Type, Type)

Adds a Singleton service implemented by the given concrete type if no service for the given service type has already been registered.

TryAddSingleton<TService,TImplementation>()

Adds a Singleton service implemented by the given concrete type if no service for the given service type has already been registered.

TryAddSingleton<TService,TImplementation>(Func<IServiceProvider,TImplementation>)

Adds a Singleton service implemented by the given factory if no service for the given service type has already been registered.

TryAddSingleton<TService>(Func<IServiceProvider,TService>)

Adds a Singleton service implemented by the given factory if no service for the given service type has already been registered.

TryAddSingleton<TService>(TService)

Adds a Singleton service implemented by the given instance if no service for the given service type has already been registered.

TryAddSingletonEnumerable(Type, Object)

Adds a Singleton service implemented by the given instance to the list of services that implement the given contract. The service is only added if the collection contains no other registration for the same service and implementation type.

TryAddSingletonEnumerable(Type, Type)

Adds a Singleton service implemented by the given concrete type to the list of services that implement the given contract. The service is only added if the collection contains no other registration for the same service and implementation type.

TryAddSingletonEnumerable<TService,TImplementation>()

Adds a Singleton service implemented by the given concrete type to the list of services that implement the given contract. The service is only added if the collection contains no other registration for the same service and implementation type.

TryAddSingletonEnumerable<TService,TImplementation>(Func<IServiceProvider,TImplementation>)

Adds a Singleton service implemented by the given factory to the list of services that implement the given contract. The service is only added if the collection contains no other registration for the same service and implementation type.

TryAddSingletonEnumerable<TService>(TService)

Adds a Singleton service implemented by the given instance to the list of services that implement the given contract. The service is only added if the collection contains no other registration for the same service and implementation type.

TryAddTransient(Type, Func<IServiceProvider,Object>)

Adds a Transient service implemented by the given factory if no service for the given service type has already been registered.

TryAddTransient(Type, Type)

Adds a Transient service implemented by the given concrete type if no service for the given service type has already been registered.

TryAddTransient<TService,TImplementation>()

Adds a Transient service implemented by the given concrete type if no service for the given service type has already been registered.

TryAddTransient<TService,TImplementation>(Func<IServiceProvider,TImplementation>)

Adds a Transient service implemented by the given factory if no service for the given service type has already been registered.

TryAddTransient<TService>(Func<IServiceProvider,TService>)

Adds a Transient service implemented by the given factory if no service for the given service type has already been registered.

TryAddTransientEnumerable(Type, Type)

Adds a Transient service implemented by the given concrete type to the list of services that implement the given contract. The service is only added if the collection contains no other registration for the same service and implementation type.

TryAddTransientEnumerable<TService,TImplementation>()

Adds a Transient service implemented by the given concrete type to the list of services that implement the given contract. The service is only added if the collection contains no other registration for the same service and implementation type.

TryAddTransientEnumerable<TService,TImplementation>(Func<IServiceProvider,TImplementation>)

Adds a Transient service implemented by the given factory to the list of services that implement the given contract. The service is only added if the collection contains no other registration for the same service and implementation type.

Explicit Interface Implementations

IInfrastructure<IInternalServiceCollectionMap>.Instance
IInfrastructure<InternalServiceCollectionMap>.Instance

Extension Methods

GetInfrastructure<T>(IInfrastructure<T>)

Gets the value from a property that is being hidden using IInfrastructure<T>.

This method is typically used by database providers (and other extensions). It is generally not used in application code.

Applies to