MicrosoftDependencyResolver class¶
Defined in
Namespace: Splat.Microsoft.Extensions.DependencyInjection
Assembly: Splat.Microsoft.Extensions.DependencyInjection.dll
Full name: Splat.Microsoft.Extensions.DependencyInjection.MicrosoftDependencyResolver
Modifiers: public
Summary¶
Provides an implementation of the dependency resolver pattern using Microsoft.Extensions.DependencyInjection.
Supports registration, resolution, and management of services with optional contract-based (keyed) registrations.
Applies to
net10.0, net10.0-desktop1.0, net10.0-browserwasm1.0, net9.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0, net8.0-ios17.5, net8.0-macos14.5, net8.0-macos14.5, net8.0-macos14.2, net8.0-macos14.2, net8.0-maccatalyst17.5, net8.0-maccatalyst17.5, net8.0-tvos17.2, net8.0-tvos17.2, net8.0-ios17.5, netstandard2.1, netstandard2.1, netstandard2.0, netstandard2.0, net481, net462
Class hierarchy
classDiagram
class MicrosoftDependencyResolver
class IDependencyResolver {
<>
}
IDependencyResolver <|.. MicrosoftDependencyResolver
class IReadonlyDependencyResolver {
<>
}
IReadonlyDependencyResolver <|.. MicrosoftDependencyResolver
class IMutableDependencyResolver {
<>
}
IMutableDependencyResolver <|.. MicrosoftDependencyResolver
class IDisposable {
<>
}
IDisposable <|.. MicrosoftDependencyResolver
class IAsyncDisposable {
<>
}
IAsyncDisposable <|.. MicrosoftDependencyResolver
Implements: IDependencyResolver, IReadonlyDependencyResolver, IMutableDependencyResolver, IDisposable, IAsyncDisposable
Remarks¶
This class enables integration with the Microsoft dependency injection container, allowing for both programmatic and externally provided service collections or providers. Once the container is built from an IServiceProvider, further modifications are not permitted. Thread safety is ensured for all registration and resolution operations. Contract-based (keyed) registrations are supported if the underlying service provider implements IKeyedServiceProvider. This resolver is suitable for scenarios requiring dynamic service registration and resolution, as well as integration with existing Microsoft.Extensions.DependencyInjection infrastructure.
Constructors¶
| Name | Summary |
|---|---|
| .ctor | Initializes a new instance of the [MicrosoftDependencyResolver](# class with a new... |
Properties¶
| Name | Summary |
|---|---|
| ServiceProvider | Gets the internal Microsoft container, or builds a new one if this instance was not initialized with one. |
Methods¶
| Name | Summary |
|---|---|
| UpdateContainer | Updates this instance with a collection of configured services. |
| GetService | Gets an instance of the given serviceType. Must return null if the service is not available (must not throw). |
| GetServices | Gets all instances of the given serviceType. Must return an empty collection if the service is not available (must not return null or throw). |
| Register | Registers a factory method for creating instances of the specified service type. |
| UnregisterCurrent | Unregisters the current instance of the specified service type from the context. |
| UnregisterAll | Unregisters all service registrations for the specified service type. |
| ServiceRegistrationCallback | Registers a callback to be invoked when a service of the specified type is registered or becomes available. |
| HasRegistration | Determines whether a registration exists for the specified service type. |
| RegisterConstant | Registers a constant value of the specified reference type for later retrieval or use. |
| RegisterLazySingleton | Registers a singleton service of type T that is created lazily using the specified factory function. |
| DisposeAsync | |
| Dispose |