Interface IMutableDependencyResolver
- Namespace
- Splat
- Assembly
- Splat.Core.dll
Represents a dependency resolver where types can be registered after setup.
- Extension Methods
Methods
HasRegistration(Type?)
Check to see if a resolver has a registration for a type.
Parameters
serviceTypeTypeThe type to check for registration.
Returns
- bool
Whether there is a registration for the type.
HasRegistration(Type?, string?)
Check to see if a resolver has a registration for a type.
Parameters
serviceTypeTypeThe type to check for registration.
contractstringA contract value which will indicates to only generate the value if this contract is specified.
Returns
- bool
Whether there is a registration for the type.
HasRegistration<T>()
Check to see if a resolver has a registration for a type.
Returns
- bool
Whether there is a registration for the type.
Type Parameters
TThe type to check for registration.
HasRegistration<T>(string?)
Check to see if a resolver has a registration for a type.
Parameters
contractstringA contract value which will indicates to only generate the value if this contract is specified.
Returns
- bool
Whether there is a registration for the type.
Type Parameters
TThe type to check for registration.
Register(Func<object?>, Type?)
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 multiple items to be registered.
Parameters
factoryFunc<object>The factory function which generates our object.
serviceTypeTypeThe type which is used for the registration.
Register(Func<object?>, Type?, string?)
Register a function with the resolver which will generate an object for the specified service type. Optionally a contract can be registered which will indicate that registration will only work with that contract. Most implementations will use a stack based approach to allow for multiple items to be registered.
Parameters
factoryFunc<object>The factory function which generates our object.
serviceTypeTypeThe type which is used for the registration.
contractstringA contract value which will indicates to only generate the value if this contract is specified.
RegisterConstant<T>(T?)
Registers a constant value which will always return the specified object instance.
Parameters
valueTThe specified instance to always return.
Type Parameters
TThe service type to register for (must be a reference type).
RegisterConstant<T>(T?, string?)
Registers a constant value which will always return the specified object instance.
Parameters
valueTThe specified instance to always return.
contractstringA contract value which will indicates to only return the value if this contract is specified.
Type Parameters
TThe service type to register for (must be a reference type).
RegisterLazySingleton<T>(Func<T?>)
Registers a lazy singleton value which will always return the specified object instance once created. The value is only generated once someone requests the service from the resolver.
Parameters
valueFactoryFunc<T>A factory method for generating a object of the specified type.
Type Parameters
TThe service type to register for (must be a reference type).
RegisterLazySingleton<T>(Func<T?>, string?)
Registers a lazy singleton value which will always return the specified object instance once created. The value is only generated once someone requests the service from the resolver.
Parameters
valueFactoryFunc<T>A factory method for generating a object of the specified type.
contractstringA contract value which will indicates to only return the value if this contract is specified.
Type Parameters
TThe service type to register for (must be a reference type).
Register<T>(Func<T?>)
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 multiple items to be registered.
Parameters
factoryFunc<T>The factory function which generates our object.
Type Parameters
TThe type which is used for the registration.
Remarks
This generic method is preferred over the non-generic Register(Func<object?>, Type?)
method for better performance and type safety. It enables optimizations in resolvers like
Global
Register<T>(Func<T?>, string?)
Register a function with the resolver which will generate an object for the specified service type. Optionally a contract can be registered which will indicate that registration will only work with that contract. Most implementations will use a stack based approach to allow for multiple items to be registered.
Parameters
factoryFunc<T>The factory function which generates our object.
contractstringA contract value which will indicates to only generate the value if this contract is specified.
Type Parameters
TThe type which is used for the registration.
Remarks
This generic method is preferred over the non-generic Register(Func<object?>, Type?, string?)
method for better performance and type safety. It enables optimizations in resolvers like
Global
Register<TService, TImplementation>()
Registers a factory for a service type that will be registered as a different type.
void Register<TService, TImplementation>() where TService : class where TImplementation : class, TService, new()
Type Parameters
TServiceThe service type to register as (interface or base class, must be a reference type).
TImplementationThe concrete implementation type (must be a reference type, have a parameterless constructor, and implement TService).
Register<TService, TImplementation>(string?)
Registers a factory for a service type that will be registered as a different type.
void Register<TService, TImplementation>(string? contract) where TService : class where TImplementation : class, TService, new()
Parameters
contractstringA contract value which will indicates to only generate the value if this contract is specified.
Type Parameters
TServiceThe service type to register as (interface or base class, must be a reference type).
TImplementationThe concrete implementation type (must be a reference type, have a parameterless constructor, and implement TService).
ServiceRegistrationCallback(Type, Action<IDisposable>)
Register a callback to be called when a new service matching the type is registered.
When registered, the callback is also called for each currently matching service.
Parameters
serviceTypeTypeThe type which is used for the registration.
callbackAction<IDisposable>The callback which will be called when the specified service type is registered.
Returns
- IDisposable
When disposed removes the callback.
ServiceRegistrationCallback(Type, string?, Action<IDisposable>)
Register a callback to be called when a new service matching the type and contract is registered.
When registered, the callback is also called for each currently matching service.
IDisposable ServiceRegistrationCallback(Type serviceType, string? contract, Action<IDisposable> callback)
Parameters
serviceTypeTypeThe type which is used for the registration.
contractstringA contract value which will indicates to only generate the value if this contract is specified.
callbackAction<IDisposable>The callback which will be called when the specified service type and contract are registered.
Returns
- IDisposable
When disposed removes the callback.
ServiceRegistrationCallback<T>(Action<IDisposable>)
Register a callback to be called when a new service matching the type is registered.
When registered, the callback is also called for each currently matching service.
Parameters
callbackAction<IDisposable>The callback which will be called when the specified service type is registered.
Returns
- IDisposable
When disposed removes the callback.
Type Parameters
TThe type which is used for the registration.
ServiceRegistrationCallback<T>(string?, Action<IDisposable>)
Register a callback to be called when a new service matching the type and contract is registered.
When registered, the callback is also called for each currently matching service.
Parameters
contractstringA contract value which will indicates to only generate the value if this contract is specified.
callbackAction<IDisposable>The callback which will be called when the specified service type and contract are registered.
Returns
- IDisposable
When disposed removes the callback.
Type Parameters
TThe type which is used for the registration.
UnregisterAll(Type?)
Unregisters all the values associated with the specified type.
Parameters
serviceTypeTypeThe service type to unregister.
UnregisterAll(Type?, string?)
Unregisters all the values associated with the specified type and contract.
Parameters
serviceTypeTypeThe service type to unregister.
contractstringThe contract value, which will only remove the value associated with the contract.
UnregisterAll<T>()
Unregisters all the values associated with the specified type.
Type Parameters
TThe service type to unregister.
UnregisterAll<T>(string?)
Unregisters all the values associated with the specified type and contract.
Parameters
contractstringThe contract value, which will only remove the value associated with the contract.
Type Parameters
TThe service type to unregister.
UnregisterCurrent(Type?)
Unregisters the current item based on the specified type.
Parameters
serviceTypeTypeThe service type to unregister.
UnregisterCurrent(Type?, string?)
Unregisters the current item based on the specified type and contract.
Parameters
serviceTypeTypeThe service type to unregister.
contractstringThe contract value, which will only remove the value associated with the contract.
UnregisterCurrent<T>()
Unregisters the current item based on the specified type.
Type Parameters
TThe service type to unregister.
UnregisterCurrent<T>(string?)
Unregisters the current item based on the specified type and contract.
Parameters
contractstringThe contract value, which will only remove the value associated with the contract.
Type Parameters
TThe service type to unregister.