InstanceGenericFirstDependencyResolver class¶
Defined in
Namespace: Splat
Assembly: Splat.Core.dll
Full name: Splat.InstanceGenericFirstDependencyResolver
Modifiers: public sealed
Summary¶
Generic-first implementation of IDependencyResolver optimized for AOT compilation, with per-resolver instance isolation using resolver-local state.
Applies to
net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481
Class hierarchy
classDiagram
class InstanceGenericFirstDependencyResolver
class IDependencyResolver {
<>
}
IDependencyResolver <|.. InstanceGenericFirstDependencyResolver
class IReadonlyDependencyResolver {
<>
}
IReadonlyDependencyResolver <|.. InstanceGenericFirstDependencyResolver
class IMutableDependencyResolver {
<>
}
IMutableDependencyResolver <|.. InstanceGenericFirstDependencyResolver
class IDisposable {
<>
}
IDisposable <|.. InstanceGenericFirstDependencyResolver
Implements: IDependencyResolver, IReadonlyDependencyResolver, IMutableDependencyResolver, IDisposable
Remarks¶
This resolver favors the generic API surface (GetService, GetServices) for performance, while still supporting non-generic APIs (GetService, GetServices) through an internal type registry.
Registration semantics:
- GetService returns the most recently registered service for the type (last registration wins).
- GetServices returns all registrations (order is implementation-defined by the underlying containers/registry).
- Contracts provide named variants of the same service type.
Disposal semantics:
- Constants and lazy singletons that implement IDisposable are disposed when the resolver is disposed.
- Exceptions thrown from callbacks or disposal actions are suppressed during Dispose.
Thread-safety:
- Registration-change callbacks and disposal action bookkeeping are thread-safe.
- Resolve operations avoid additional locking within this type; underlying containers/registry are expected to be concurrency-safe for their usage patterns.
Constructors¶
| Name | Summary |
|---|---|
| .ctor | Initializes a new instance of the [InstanceGenericFirstDependencyResolver](# class. |
Methods¶
| Name | Summary |
|---|---|
| GetService | Gets an instance of the given T. Must return null if the service is not available (must not throw). |
| GetServices | Gets all instances of the given T. Must return an empty collection if the service is not available (must not return null or throw). |
| HasRegistration | Determines whether a registration exists for the specified service type. |
| Register | Register a function with the resolver which will generate an object for the specified service type. Most implementations will use a stack based approach to allow for... |
| 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. |
| UnregisterCurrent | Unregisters the current instance of the specified type from the context. |
| UnregisterAll | Unregisters all instances of the specified type from the registry or container. |
| ServiceRegistrationCallback | Registers a callback to be invoked when a service of type T is registered, and returns a disposable object that can be used to unregister the callback. |
| Dispose |