EmptyServiceProvider Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides an IServiceProvider that contains no application services.
public ref class EmptyServiceProvider sealed : IServiceProvider, Microsoft::Extensions::DependencyInjection::IKeyedServiceProvider, Microsoft::Extensions::DependencyInjection::IServiceProviderIsKeyedService
public sealed class EmptyServiceProvider : IServiceProvider, Microsoft.Extensions.DependencyInjection.IKeyedServiceProvider, Microsoft.Extensions.DependencyInjection.IServiceProviderIsKeyedService
type EmptyServiceProvider = class
interface IKeyedServiceProvider
interface IServiceProvider
interface IServiceProviderIsKeyedService
interface IServiceProviderIsService
Public NotInheritable Class EmptyServiceProvider
Implements IKeyedServiceProvider, IServiceProvider, IServiceProviderIsKeyedService
- Inheritance
-
EmptyServiceProvider
- Implements
Remarks
Like the IServiceProvider returned by new ServiceCollection().BuildServiceProvider(), this provider still exposes the built-in services (IServiceProvider, IServiceScopeFactory, IServiceProviderIsService and IServiceProviderIsKeyedService) and resolves requests for IEnumerable<T> to an empty sequence.
Use Instance to access the shared singleton instead of writing a custom empty provider.
Properties
| Name | Description |
|---|---|
| Instance |
Gets the shared EmptyServiceProvider instance. |
Explicit Interface Implementations
| Name | Description |
|---|---|
| IKeyedServiceProvider.GetKeyedService(Type, Object) |
Gets the service object of the specified type. |
| IKeyedServiceProvider.GetRequiredKeyedService(Type, Object) |
Gets service of type |
| IServiceProvider.GetService(Type) |
Gets the service object of the specified type. |
| IServiceProviderIsKeyedService.IsKeyedService(Type, Object) |
Determines if the specified service type with the specified service key is available from the IServiceProvider. |
| IServiceProviderIsService.IsService(Type) |
Determines if the specified service type is available from the IServiceProvider. |