I'm in trouble. I have a class named Money and represents exactly that: Money. Money in any currency. I love it because I can add and subtract money objects and always get a correct result regardless of the differences
in currency. I also love it because its ToString() method returns the value properly formatted with the expected currency symbol.
Now today I want to serialize Money objects into XML. I went ahead and provided a type converter that can convert to and from a string of the form "value ISOCode". Examples: "100 USD", "500 CRC", "30 MXN", "50 EUR". The value part
is expected to be serialized using the invariant culture. I think this would be the best option for serialization.
The problem I have is that the XmlSerializer will not use the type converter. Instead it will serialize the class as usual, property by property and put it as a child node of the containing class.
How can I make the XmlSerializer serialize Money objects as string using the provided type converter? Note that
IXmlSerializer is not an option because I want the Money
class to be serialized as an attri
View Complete Post