This project has moved. For the latest updates, please go here.

Style Serialization

Topics: SharpMap v2.0
Oct 24, 2008 at 12:33 PM
On wednesday at the developer irc, you said you were using serialization with geometrystyles to store them in a database.
You have wrapper classes for that, don't you?

Just using the BinaryFormatter or XMLSerializer does not work for me (complaining that SolidStyleBrush does not have the [Serializable] Attribute.


Oct 24, 2008 at 8:50 PM
I did serialize styles via XML, but I don't have the code anymore... it was my previous employer's.

I can tell you that all we did was to create an XSD which described all of the SharpMap.Style classes and then just ran xsd.exe over it to generate serialization classes. Then we developed a conversion utility to copy to and from the serialized "style storage" object to the corresponding SharpMap.Styles object.

I could try to recreate an XSD which would get you bootstrapped... not sure exactly about when I could do this, though.
Oct 24, 2008 at 11:02 PM
Well, it was easier than I thought. Since I was in that area of the code, I started thinking about generating the XSD from the code... then I played around with xsd, and sure enough, it can do it. I ran xsd on the style types, then combined them and changed a few of the resultant schema types to look nicer and the names to indicate that the generated classes are just for storage, and here you go:

You can just run xsd.exe on that and it will create classes you can use to store style data in and then serialize. You'll have to write a Storage->Style->Storage converter, however...
Oct 25, 2008 at 6:51 PM
thanks for the hint and the xsd-file.