Created
June 26, 2017 08:25
-
-
Save lbargaoanu/34a397a5ced65d8d2547c4440893a0ee 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
public void Main() | |
{ | |
Mapper.Initialize(cfg => | |
{ | |
cfg.CreateMap<ExpandoObject, Destination>().ConvertUsing((expando, destination, context)=> | |
{ | |
var dictionary = context.Mapper.Map<Dictionary<string,object>>(expando); | |
context.Mapper.Map(dictionary, destination); | |
// after map | |
return destination; | |
}); | |
}); | |
Mapper.AssertConfigurationIsValid(); | |
dynamic source = new ExpandoObject(); | |
source.Id = 34; | |
source.Name = "thirty four"; | |
var dest = new Destination(); | |
Mapper.Map(source, dest); | |
dest.Dump(); | |
} | |
class Destination | |
{ | |
public int Id { get; set; } | |
public string Name { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment