I wrote an article on Code Project in which I describe an easy-to-use general purpose base class for data transfer objects that leverage XML Serialization in the .NET Framework. The base class has a number of overloaded Save and Load methods which are useful for eliminating repetitive code. An added benefit is that, by deriving from this common base class, all XML Serializable objects can be treated polymorphically.
Keep in mind, I've designed this class for simplicity. If you need access to some of the richer features of the Xml Serializer such as customized type mappings and namespaces, or wish to respond to deserialization events, then you'll have to extend the base class to support this functionality. Also, if your class already inherits from some other base class, then this class simply won't work for you. That said, I've found this class to handle my needs in most cases, where I just want a quick and easy way to save my object's state as XML.
Posted by Christian at July 8, 2003 04:18 PM |