Created
July 17, 2018 06:39
-
-
Save lbargaoanu/534b00577399dffa6ef463c88de001b9 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() | |
{ | |
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