Serializable base class added to XSDToClasses project

xsdAt the prompting (or complaint) of a reader, I’ve shared a base class that I use with my code generator.

The generated code is “pure” in that it doesn’t contain any methods that don’t have to do with the data — it doesn’t implement saving and loading methods. I could create a codemodifier for this, but it could just cause trouble. However, this leaves users writing the saving and loading code over and over, and we can’t have that.

An XSD can express inheritance. Generating save and load methods for every class would cause lots of warnings and duplicated code. So I’ve created a generic base class that contains a bunch of utility methods including the save and load methods. If you want to have these in a class, just inherit the partial class from this base class and you’re ready to go.

There is an example project that shows you how to use it. There’s also a nifty serializable color class. It’s not going to work in every circumstance (for example if  your class is already inheriting), but it should reduce the amount of code you need to write.

You can find the download at google code here.

Leave a Reply