Table of Contents

Class MapperHost

Namespace
Mapperion
Assembly
Mapperion.dll

Holds one mapper for code that has no way to receive it, such as a .NET Framework application without a container.

public static class MapperHost
Inheritance
MapperHost
Inherited Members

Remarks

This is a last resort and is documented as one. A mapper reached through a static property is a dependency the signature does not declare: it cannot be substituted in a test without touching global state, and two parts of a process cannot use different configurations. Take an IMapper as a constructor parameter wherever that is possible, and register it with AddMapperion when there is a container.

It exists because AutoMapper had a static Mapper.Map until v4, and a codebase still carrying those call sites should be able to migrate without rewriting them all at once. Treat it as a step on the way, not a destination.

Properties

Instance

Gets the installed mapper.

IsInitialized

Gets a value indicating whether a mapper has been installed.

Methods

Initialize(IMapper)

Installs the mapper every call to Instance will return.

Reset()

Removes the installed mapper, so another one can be installed.