Dependency injection

Lucian Bargaoanu edited this page Oct 17, 2016 · 2 revisions

AutoMapper supports the ability to construct Custom Value Resolvers and Custom Type Converters using static service location:

    Mapper.Initialize(cfg =>

        cfg.CreateMap<Source, Destination>();

Or dynamic service location, to be used in the case of instance-based containers (including child/nested containers):

    var mapper = new Mapper(Mapper.Configuration, childContainer.GetInstance);

    var dest = mapper.Map<Source, Destination>(new Source { Value = 15 });


There is a NuGet package to be used with the default injection mechanism described here.