Last active
March 18, 2016 13:48
-
-
Save lbargaoanu/fddbecb1479c30b19c6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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