I have a scenario close to the one in this thread . I wanted to provide a more specific example but wasn't sure how to ask it on that thread and make it look pretty. So I started this one. I have a collection of BaseObjects within a class. I would like to Deserialize this class with the Xml output of the mixed collection of derived classes.
public class RootElementClass
{
public BaseTypeCollection Collection{ get; set; }
}
public class BaseType { public int Id{get;set;} }
public class BaseTypeCollection : System.ComponentModel.BindingList<BaseType>{}
public class Derived1BaseType : BaseType { public string Derived1Name{get;set;} }
public class Derived2BaseType : BaseType { public string Derived2Name{get;set;}
public string DerivedOtherProperty{get;set;} }
How do I get an output of something like this:
<RootElementClass>
<Collection>
<BaseObject>
<Id>...</Id>
<Derived1Name>...</Derived1Name>
</BaseObject>
<BaseObject>
<Id>...</Id>
<Derived2Name>...</Derived2Name>
<DerivedOtherProperty>...</DerivedOtherProperty>
</BaseObject>
</Collection>
</RootElementClass>