Skip to content

Instantly share code, notes, and snippets.

@lbargaoanu
Created July 17, 2018 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbargaoanu/534b00577399dffa6ef463c88de001b9 to your computer and use it in GitHub Desktop.
Save lbargaoanu/534b00577399dffa6ef463c88de001b9 to your computer and use it in GitHub Desktop.
void Main()
{
Mapper.Initialize(cfg=>
{
cfg.CreateMap<object, bool>().ConvertUsing(o=>o!=null);
cfg.RecognizeDestinationPostfixes("Specified");
});
Mapper.AssertConfigurationIsValid();
Mapper.Map<Destination>(new Source { Value = 0 }).Dump();
Mapper.Map<Destination>(new Source { Value = 13 }).Dump();
Mapper.Map<Destination>(new Source { Value = null }).Dump();
}
class Source
{
public int? Value { get; set; }
}
class Destination
{
public int Value { get; set; }
public bool ValueSpecified { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment