How do you serialize the following
[XmlRoot("response")]
public class MyCollection<T>
{
[XmlElement("person", Type = typeof(Person))]
public List<T> entry;
public int startIndex;
}
where T can be a class like
public class Person
{
public string name;
}
into
<response>
<startIndex>1</startIndex>
<entry>
<person>
<name>meeee</name>
</person>
</entry>
<entry>
<person>
<name>youuu</name>
</person>
</entry>
</response>
I have been playing with [XmlArray], [XmlArrayItem], and [XmlElement] and I can't seem to get the right combination. Arrrgghhh.
Update:
[XmlArray("entry")]
[XmlArrayItem("person", Type = typeof(Person))]
public List<T> entry;
gives me
<entry><person></person><person></person></entry>
[XmlElement("person", Type = typeof(Person))]
public List<T> entry;
gives me
<person></person><person></person>