Currently, the ConvertTo method does not handle mapping of two identically named properties, where the value in the source object is an int and the value in the target is an enum. I would have expected the method to convert the int value to the correlated enum value or throw an exception if no enum with that int value exists. How can I extend the ConvertTo method to work this way (or even, better, perhaps this is worthy of a change in the ConvertTo source since it seems like universal behavior)?
class Source
{
int myProperty {get;set;}
}
class Target
{
MyEnum myProperty {get;set;}
}
Source instanceOfSource = new Source() {myProperty = 1;}
Target instanceOfTarget = instanceOfSource.ConvertTo<Target>();
[EnumAsInt]
public enum MyEnum
{
OneValue = 1,
AnotherValue = 2,
ThirdValue = 4
};