I am trying to map a source type to two destination types by using AutoMapper:
public class Source
{
public string Value1 { get; set; }
public string Value2 { get; set; }
public Source[] Values { get; set; }
}
public interface IDest
{
}
public class DestinationSimple : IDest
{
public string Value1 { get; set; }
}
public class DestinationComplex : IDest
{
public string Value2 { get; set; }
public IDest[] Values { get; set; }
}
Destination type to map to should be based on the property values in the source type. If Value1 in Source is not null, destination type should be DestinationSimple. Otherwise destination type should be DestinationComplex.
Which way is the best to proceed? I have tried to use a custom type converter, but I couldn't get it to work because I didn't know how to handle the Values property.