Hi
I've been reading using the XmlSerializer with custom collections.
I've discovered that when serializing a custom collection (a class that
implements ICollection, IList etc.) the XmlSerializer will only serialize
the collection items - with the default root as ArrayofMyItems etc.
My custom collection class has some additional public properties that I
would like to include in the serialization above the items element array (in
my own root) - but if I've understood this correctly XmlSerializer will only
serialize a collection via the collection interface - ignoring all other
public collection properties. I understand the reason for this - it
considers these as auxilary - and that they should be recreated when the
class is deserialized.
In my case I have a couple of special integer properties that include
statistical information about the collection - i.e. data that was included
when the collection was originally created - but can not be recreated during
deserialiation of the collection items only.
I want the format of the XmlSerializer - and not the SOAP formater (which I
could use if I implement ISerializable - adding my properties to the object
graph).
Any suggestions? Or will I simply have to write my own Xml document helper
method to produce the Xml version of this class?
Any tips or advice greatly appreciated,
Tony