I have the following class:
public class SomeClass
{
public double SomeValue {get;set;}
}
I need to serialize it by XmlSerializer but I need to multiply the value by 10 during serialization and divide it by 10 during deserialization. Is there any way to implement this custom logic?
This might be a bit hacky, but involves not serialising your main property, but providing a dummy property for the purposes of serialization that gets/sets the backing field for your main propery appropriately.
Edit: Would note, the implementation of IXmlSerializable is probably a cleaner way to do this, but it really depends on the number of fields on your class and how lazy you’re feeling…