Skip to content

Instantly share code, notes, and snippets.

@lbargaoanu
Created August 11, 2017 17:43
Show Gist options
  • Save lbargaoanu/8716aedde92f4ff98c2c57d41da1e5a1 to your computer and use it in GitHub Desktop.
Save lbargaoanu/8716aedde92f4ff98c2c57d41da1e5a1 to your computer and use it in GitHub Desktop.
void Main()
{
Mapper.Initialize(cfg =>
{
cfg.CreateMap<Source, Destination>();
cfg.CreateMap<Source, IDestination>().As<Destination>();
});
Mapper.AssertConfigurationIsValid();
Mapper.Map<IDestination>(new Source { Value = Guid.NewGuid().ToString(), TypedValue = Guid.NewGuid() }).Dump();
}
class Source
{
public string Value;
public Guid? TypedValue;
}
class Destination : IDestination
{
public Guid? Value { get; set; }
public string TypedValue { get; set; }
}
interface IDestination
{
Guid? Value { get; set; }
string TypedValue { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment