Использовать API-интерфейс экземпляра автоматического инструмента.
public class AutomapperConfiguration : Profile
{
public static MapperConfiguration Get()
{
return new MapperConfiguration(cfg =>
{Mapper.Initialize(cfg =>{cfg.CreateMap<A,B>();});
}
}
}
В Registries.cs
public class Registries
{
public static UnityContainer GetContainer(MapperConfiguration config)
{
var container = new UnityContainer();
container.RegisterInstance<IMapper>(new Mapper(config), new
ContainerControlledLifetimeManager());
}
}
В Webapiconfig.cs
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
var automapperConfig = AutomapperConfiguration.Get();
var container = Registries.GetContainer(automapperConfig);
}
}