AutoMapper Extension

The Automapper extension purpose is to initialize Automapper. When Bootstrapper is invoked the Automapper extension will look for classes implementing IMapCreator and will execute it's CreateMap.

Installation

You can install the Automapper extensions via nuget over here.

Creating maps

To initialize your maps you must declare classes that implements IMapCreator and implement the CreateMap method. For example:
    public class MyMapCreator: IMapCreator
    {
        public void CreateMap(IProfileExpression mapper)
        {
            mapper.CreateMap<Type1, Type2>();
        }
    }

Native Registrations (new in 2.0.3.0)

Bootstrapper now supports the use of native registrations for mappers. Native registrations can be used by themselves or in conjunction with MapCreator classes. For AutoMapper just declare a class that inherits from AutoMapper.Profile and Bootstrapper will use it to initialize AutoMapper.
     public class TestAutoMapperProfile: Profile
    {
        protected override void Configure()
        {
            Mapper.CreateMap<ITestInterface, TestImplementation>();
        }
    }

Using the extension

To use the extension simply write this code:
Bootstrapper.With.AutoMapper().Start();

Last edited Mar 3, 2013 at 7:57 AM by luisbocaletti, version 6

Comments

jbogard Jun 5, 2014 at 9:40 PM 
Small thing - in the native registrations, call just CreateMap, not Mapper.CreateMap.