I have some class with "complex" objects like Enumerators, Lists and others. I need to construct the same anonymous object from instance of this class. However, I need to convert all enumerators, bools, Lists and some others types in a way I want.
public class MyClass {
public string Str1 {get;set;}
public bool B1 {get;set;}
public MyEnum EnumVal {get;set;}
}
So the instance of this
var cl = new MyClass() { Str1 = "Some rand", B1 = true, EnumVal = MyEnum.Value1 } ;
should be converted into some anonymous class with values:
{ Str1 = "Some rand", B1 = 1, EnumVal = 1 }
I thought about having two classes like MyClass and MySimplifiedClass and use AutoMapper, but in future MyClass could be extended and I do not want manually add properties to MySimplifiedClass. Instead I have defined rules how some of types should be converted (these are booleans, enumerators, Lists).