Skip to content

Instantly share code, notes, and snippets.

@lbargaoanu
Last active March 18, 2016 13:48
Show Gist options
  • Save lbargaoanu/fddbecb1479c30b19c6d to your computer and use it in GitHub Desktop.
Save lbargaoanu/fddbecb1479c30b19c6d to your computer and use it in GitHub Desktop.
void Main()
{
var config = new AutoMapper.MapperConfiguration(c =>
{
c.CreateMap<B, A>();
c.CreateMap<A, AB>();
c.CreateMap<B, AB>();
});
var mapper = config.CreateMapper();
var runtimeMapper = (IRuntimeMapper) mapper;
var b = new B() { a = 1, b = 2 };
var typeMap = config.ResolveTypeMap(typeof(A), typeof(AB));
var options = new MappingOperationOptions(mapper.ServiceCtor);
var context = new ResolutionContext(b, null, typeof(A), typeof(AB), typeMap, options, runtimeMapper);
runtimeMapper.Map(context).Dump();
}
class A
{
public int a { get; set; }
}
class B : A
{
public int b { get; set; }
}
class AB
{
public int a { get; set; }
public int b { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment