Class DependencyResolverMixins
- Namespace
- Splat
- Assembly
- Splat.Core.dll
A set of extension methods that assist with the IDependency
- Inheritance
-
Dependency
Resolver Mixins
Methods
RegisterConstant(IMutableDependencyResolver, object?, Type)
Registers a constant value which will always return the specified object instance.
public static void RegisterConstant(this IMutableDependencyResolver resolver, object? value, Type serviceType)
Parameters
resolverIMutableDependency Resolver The resolver to register the service type with.
valueobjectThe specified instance to always return.
serviceTypeTypeThe type of service to register.
RegisterConstant(IMutableDependencyResolver, object?, Type, string)
Registers a constant value which will always return the specified object instance.
public static void RegisterConstant(this IMutableDependencyResolver resolver, object? value, Type serviceType, string contract)
Parameters
resolverIMutableDependency Resolver The resolver to register the service type with.
valueobjectThe specified instance to always return.
serviceTypeTypeThe type of service to register.
contractstringA contract value which will indicates to only return the value if this contract is specified.
RegisterLazySingleton(IMutableDependencyResolver, Func<object?>, Type)
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.
public static void RegisterLazySingleton(this IMutableDependencyResolver resolver, Func<object?> valueFactory, Type serviceType)
Parameters
resolverIMutableDependency Resolver The resolver to register the service type with.
valueFactoryFunc<object>A factory method for generating a object of the specified type.
serviceTypeTypeThe type of service to register.
RegisterLazySingleton(IMutableDependencyResolver, Func<object?>, Type, 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.
public static void RegisterLazySingleton(this IMutableDependencyResolver resolver, Func<object?> valueFactory, Type serviceType, string contract)
Parameters
resolverIMutableDependency Resolver The resolver to register the service type with.
valueFactoryFunc<object>A factory method for generating a object of the specified type.
serviceTypeTypeThe type of service to register.
contractstringA contract value which will indicates to only return the value if this contract is specified.
WithResolver(IDependencyResolver, bool)
Override the default Dependency Resolver until the object returned is disposed.
public static IDisposable WithResolver(this IDependencyResolver resolver, bool suppressResolverCallback = true)
Parameters
resolverIDependencyResolver The test resolver to use.
suppressResolverCallbackboolIf we should suppress the resolver callback notify.
Returns
- IDisposable
A disposable which will reset the resolver back to the original.