Table of Contents

Class DependencyResolverMixins

Namespace
Splat
Assembly
Splat.Core.dll

A set of extension methods that assist with the IDependencyResolver and IMutableDependencyResolver interfaces.

public static class DependencyResolverMixins
Inheritance
DependencyResolverMixins

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

resolver IMutableDependencyResolver

The resolver to register the service type with.

value object

The specified instance to always return.

serviceType Type

The 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

resolver IMutableDependencyResolver

The resolver to register the service type with.

value object

The specified instance to always return.

serviceType Type

The type of service to register.

contract string

A 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

resolver IMutableDependencyResolver

The resolver to register the service type with.

valueFactory Func<object>

A factory method for generating a object of the specified type.

serviceType Type

The 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

resolver IMutableDependencyResolver

The resolver to register the service type with.

valueFactory Func<object>

A factory method for generating a object of the specified type.

serviceType Type

The type of service to register.

contract string

A 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

resolver IDependencyResolver

The test resolver to use.

suppressResolverCallback bool

If we should suppress the resolver callback notify.

Returns

IDisposable

A disposable which will reset the resolver back to the original.