Table of Contents

Class AutofacDependencyResolver

Namespace
Splat.Autofac
Assembly
Splat.Autofac.dll

Autofac implementation for IDependencyResolver.

public class AutofacDependencyResolver : IDependencyResolver, IReadonlyDependencyResolver, IMutableDependencyResolver, IDisposable
Inheritance
AutofacDependencyResolver
Implements
Extension Methods
WhenAnyMixin.WhenAny<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(TSender?, Expression<Func<TSender, T1>>, Expression<Func<TSender, T2>>, Expression<Func<TSender, T3>>, Expression<Func<TSender, T4>>, Expression<Func<TSender, T5>>, Expression<Func<TSender, T6>>, Expression<Func<TSender, T7>>, Expression<Func<TSender, T8>>, Expression<Func<TSender, T9>>, Expression<Func<TSender, T10>>, Expression<Func<TSender, T11>>, Expression<Func<TSender, T12>>, Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, IObservedChange<TSender, T4>, IObservedChange<TSender, T5>, IObservedChange<TSender, T6>, IObservedChange<TSender, T7>, IObservedChange<TSender, T8>, IObservedChange<TSender, T9>, IObservedChange<TSender, T10>, IObservedChange<TSender, T11>, IObservedChange<TSender, T12>, TRet>)
WhenAnyMixin.WhenAny<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(TSender?, Expression<Func<TSender, T1>>, Expression<Func<TSender, T2>>, Expression<Func<TSender, T3>>, Expression<Func<TSender, T4>>, Expression<Func<TSender, T5>>, Expression<Func<TSender, T6>>, Expression<Func<TSender, T7>>, Expression<Func<TSender, T8>>, Expression<Func<TSender, T9>>, Expression<Func<TSender, T10>>, Expression<Func<TSender, T11>>, Expression<Func<TSender, T12>>, Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, IObservedChange<TSender, T4>, IObservedChange<TSender, T5>, IObservedChange<TSender, T6>, IObservedChange<TSender, T7>, IObservedChange<TSender, T8>, IObservedChange<TSender, T9>, IObservedChange<TSender, T10>, IObservedChange<TSender, T11>, IObservedChange<TSender, T12>, TRet>)
WhenAnyMixin.WhenAny<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(TSender?, Expression<Func<TSender, T1>>, Expression<Func<TSender, T2>>, Expression<Func<TSender, T3>>, Expression<Func<TSender, T4>>, Expression<Func<TSender, T5>>, Expression<Func<TSender, T6>>, Expression<Func<TSender, T7>>, Expression<Func<TSender, T8>>, Expression<Func<TSender, T9>>, Expression<Func<TSender, T10>>, Expression<Func<TSender, T11>>, Expression<Func<TSender, T12>>, Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, IObservedChange<TSender, T4>, IObservedChange<TSender, T5>, IObservedChange<TSender, T6>, IObservedChange<TSender, T7>, IObservedChange<TSender, T8>, IObservedChange<TSender, T9>, IObservedChange<TSender, T10>, IObservedChange<TSender, T11>, IObservedChange<TSender, T12>, TRet>)
WhenAnyMixin.WhenAny<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(TSender?, Expression<Func<TSender, T1>>, Expression<Func<TSender, T2>>, Expression<Func<TSender, T3>>, Expression<Func<TSender, T4>>, Expression<Func<TSender, T5>>, Expression<Func<TSender, T6>>, Expression<Func<TSender, T7>>, Expression<Func<TSender, T8>>, Expression<Func<TSender, T9>>, Expression<Func<TSender, T10>>, Expression<Func<TSender, T11>>, Expression<Func<TSender, T12>>, Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, IObservedChange<TSender, T4>, IObservedChange<TSender, T5>, IObservedChange<TSender, T6>, IObservedChange<TSender, T7>, IObservedChange<TSender, T8>, IObservedChange<TSender, T9>, IObservedChange<TSender, T10>, IObservedChange<TSender, T11>, IObservedChange<TSender, T12>, TRet>)

Constructors

AutofacDependencyResolver(ContainerBuilder)

Initializes a new instance of the AutofacDependencyResolver class.

public AutofacDependencyResolver(ContainerBuilder builder)

Parameters

builder ContainerBuilder

Autofac container builder.

Methods

Dispose()

public void Dispose()

Dispose(bool)

Disposes of the instance.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

Whether or not the instance is disposing.

GetService(Type?, string?)

Gets an instance of the given serviceType. Must return null if the service is not available (must not throw).

public virtual object? GetService(Type? serviceType, string? contract = null)

Parameters

serviceType Type

The object type.

contract string

A optional value which will retrieve only a object registered with the same contract.

Returns

object

The requested object, if found; null otherwise.

GetServices(Type?, string?)

Gets all instances of the given serviceType. Must return an empty collection if the service is not available (must not return null or throw).

public virtual IEnumerable<object> GetServices(Type? serviceType, string? contract = null)

Parameters

serviceType Type

The object type.

contract string

A optional value which will retrieve only objects registered with the same contract.

Returns

IEnumerable<object>

A sequence of instances of the requested serviceType. The sequence should be empty (not null) if no objects of the given type are available.

HasRegistration(Type?, string?)

Check to see if a resolvers has a registration for a type.

public bool HasRegistration(Type? serviceType, string? contract = null)

Parameters

serviceType Type

The type to check for registration.

contract string

A optional 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.

Register(Func<object?>, Type?, string?)

Important: Because Autofac 5+ containers are immutable, this method should not be used by the end-user. It is still needed to satisfy ReactiveUI initialization procedure. Register a function with the resolver which will generate a 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.

[Obsolete("Because Autofac 5+ containers are immutable, this method should not be used by the end-user.")]
public virtual void Register(Func<object?> factory, Type? serviceType, string? contract = null)

Parameters

factory Func<object>

The factory function which generates our object.

serviceType Type

The type which is used for the registration.

contract string

A optional contract value which will indicates to only generate the value if this contract is specified.

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.

public virtual IDisposable ServiceRegistrationCallback(Type serviceType, string? contract, Action<IDisposable> callback)

Parameters

serviceType Type

The type which is used for the registration.

contract string

A optional contract value which will indicates to only generate the value if this contract is specified.

callback Action<IDisposable>

The callback which will be called when the specified service type and contract are registered.

Returns

IDisposable

When disposed removes the callback.

SetLifetimeScope(ILifetimeScope)

Sets the lifetime scope which will be used to resolve ReactiveUI services. It should be set after Autofac application-wide container is built.

public void SetLifetimeScope(ILifetimeScope lifetimeScope)

Parameters

lifetimeScope ILifetimeScope

Lifetime scope, which will be used to resolve ReactiveUI services.

UnregisterAll(Type?, string?)

Because Autofac 5+ containers are immutable, UnregisterAll method is not available anymore. Instead, simply register your service after InitializeReactiveUI to override it.

[Obsolete("Because Autofac 5+ containers are immutable, UnregisterAll method is not available anymore. Instead, simply register your service after InitializeReactiveUI to override it https://autofaccn.readthedocs.io/en/latest/register/registration.html#default-registrations.")]
public virtual void UnregisterAll(Type? serviceType, string? contract = null)

Parameters

serviceType Type

The service type to unregister.

contract string

The optional contract value, which will only remove the value associated with the contract.

Exceptions

NotImplementedException

This is not implemented by default.

UnregisterCurrent(Type?, string?)

Because Autofac 5+ containers are immutable, UnregisterCurrent method is not available anymore. Instead, simply register your service after InitializeReactiveUI to override it.

[Obsolete("Because Autofac 5+ containers are immutable, UnregisterCurrent method is not available anymore. Instead, simply register your service after InitializeReactiveUI to override it https://autofaccn.readthedocs.io/en/latest/register/registration.html#default-registrations.")]
public virtual void UnregisterCurrent(Type? serviceType, string? contract = null)

Parameters

serviceType Type

The service type to unregister.

contract string

The optional contract value, which will only remove the value associated with the contract.

Exceptions

NotImplementedException

This is not implemented by default.