I generated a class from a schema. One of the fields are typed as
System.Guid. Perfect.
The only problem is when this class serializes, the guid field serializes as
8c4a969b-2aa4-4679-b170-d9f6441f7c6d, when I need it as
{8A3ACA06-A7DE-41A5-B584-063E7CF391BB}, all upper, and with braces.
Is there a way to force the XmlSerializer to serialize as the latter format?
I tried to turn the field into a string property with private field type
Guid. That way, I can store it as a guid but format it the way I want. The
problem this time - the properties serialize last and my elements are now
out of order.
Is there a way to force a certain order in serialization?
I am looking at a few options:
1. turn all fields into properties.
2. write a custom XmlWriter which will replace all guid fields into the
correct format upon serializing.
3. write a custom XmlReader which will replace all guid fields into the
correct format upon deserializing.
4. use xsl transformation.
It seems to me that option #1 is the easiest to implement but that would
mean my class cannot be generated automatically any more.
Any other suggestions?
Thanks much.
Jiho