Skip to content

SimpleInjectorDependencyResolver class

Defined in

Namespace: Splat.SimpleInjector Assembly: Splat.SimpleInjector.dll Full name: Splat.SimpleInjector.SimpleInjectorDependencyResolver Modifiers: public

Summary

View source

        Provides an implementation of the IDependencyResolver interface using a SimpleInjector container for dependency
        resolution.

Applies to

net10.0, net9.0, net8.0, net462, net481

Class hierarchy
classDiagram
class SimpleInjectorDependencyResolver
class IDependencyResolver {
    <>
}
IDependencyResolver <|.. SimpleInjectorDependencyResolver
class IReadonlyDependencyResolver {
    <>
}
IReadonlyDependencyResolver <|.. SimpleInjectorDependencyResolver
class IMutableDependencyResolver {
    <>
}
IMutableDependencyResolver <|.. SimpleInjectorDependencyResolver
class IDisposable {
    <>
}
IDisposable <|.. SimpleInjectorDependencyResolver

Implements: IDependencyResolver, IReadonlyDependencyResolver, IMutableDependencyResolver, IDisposable

Remarks

This resolver adapts a SimpleInjector Container to the IDependencyResolver abstraction, enabling integration with frameworks or components that expect this interface.

SimpleInjector has no keyed registrations, so a contract cannot be expressed inside the container. Contract registrations are held beside the container instead and are only ever returned to a caller asking for the same contract; a contract-less lookup never sees them, and two implementations registered under different contracts stay distinct.

Registration goes straight into the container, so anything registered here is also injectable by SimpleInjector. SimpleInjector locks its container on the first resolution, so a registration attempted after the first service has been resolved fails with SimpleInjector's own exception. Register everything up front - through SimpleInjectorInitializer or against the container - before resolving.

Service unregistration and registration callbacks are not supported, as SimpleInjector does not provide mechanisms for removing registrations or observing registration events after initial configuration. The resolver manages the lifetime of the underlying container and disposes it when the resolver is disposed.

Constructors

NameSummary
.ctorInitializes a new instance of the [SimpleInjectorDependencyResolver](# class.

Methods

NameSummary
GetServiceGets an instance of the given serviceType. Must return null if the service is not available (must not throw).
GetServicesGets all instances of the given serviceType. Must return an empty collection if the service is not available (must not return null or throw).
HasRegistrationDetermines whether a registration exists for the specified service type.
RegisterRegisters a factory method for creating instances of the specified service type.
UnregisterCurrentUnregisters the current instance of the specified service type from the context.
UnregisterAllUnregisters all service registrations for the specified service type.
ServiceRegistrationCallbackRegisters a callback to be invoked when a service of the specified type is registered or becomes available.
RegisterConstantRegisters a constant value of the specified reference type for later retrieval or use.
RegisterLazySingletonRegisters a singleton service of type T that is created lazily using the specified factory function.
DisposePerforms application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Inherited members