Posted By: ScanIAm | Oct 24th, 2008 @ 8:14 AM
page 1 of 1
Comments: 1 | Views: 393
ScanIAm
ScanIAm
On a scale of 1 to 10, people are stupid.
I have a class that contains a list of objects.  I need to specify both the order that the list appears as well as the name of the elements in the list.

i.e.

public class outer
{
    [XmlElement(Order=0)]
    public string A {get; set;}

    public List<WronglyNamedObjectType> MyList = new List<WronglyNamedObjectType>();

    [XmlElement(Order=2)]
    public string C{get; set;}
}

I want to be able to

1) apply an order to how the serialization occurs such that MyList comes between A and C when 'outer' is serialized.
2) be able to tell the serializer to name the elements contained in the list something other than 'WronglyNamedOjbectType'.

1 is satisfied by placing [XmlElement(Order=1)] above the property
2 is satisfied by placing [XmlArrayItem("BetterName")] above the property

For some unknown and undefined reason, both are not allowed?

Any ideas?
page 1 of 1
Comments: 1 | Views: 393
Microsoft Communities