I have a complex class heirarchy where all of my classes inherit from a
single base class (BaseObject) and this BaseObject class inherits from
XPBaseObject. XPBaseObject is a 3rd party base class from Express
Persistent Objects (XPO) from DevExpress. It looks kind of like
this...
BaseObject - (inherits XPBaseObject)
UserCase - (root object in my heirarchy - inherits from BaseObject)
- UserCase has many properties, some of which are other objects,
UserCase also has collections of other objects. All complex objects
inherit from BaseObject also
I want to use XML serialization so that I can save a UserCase object
(and all of it's properties and collecitons) to an XML file and then
later repopulate it in my application. Unfortunately XPBaseObject does
not support serialization. I have been in contact with tech support at
DevExpress and have been told that if I just implement the
IXMLSerializable interface in my BaseObject class then the
serialization should work fine.
So it looks like all I need to do is implement the follow items:
WriteXML(), ReadXML(), and GetSchema(). [I am using .NET v1.1]
I have implemented WriteXML and it works fine. I was able to write a
generic WriteXML method for my base class that examines the properties
and uses recursion to write out a nice XML file. I used custom
attributes on my properties for my different classes to determine if
they need to be written to the XML file or not. (Some properties are
read only and don't need to be written to the XML file).
But now I am stuck and not sure what I should do next. The tech
support person at DevExpress has told me that the only other thing I
need to do is implement GetSchema and it should work - I don't need to
implement anything for ReadXML. However I have read other posts at
other web sites that say that I should implement ReadXML so that my
classes know how to convert the XML file back to an object. I am
looking for a little help in understanding exactly how this XML
deserialization works. Does .NET use the schema to figure out how to
populate the object with data from the XML file? I can't figure out
how to write a generic GetSchema method for my base class that will
work correctly. Can anyone help me maybe with some pseudo code? I can
post some code snippets if that would help.
Thanks,
Corey