I am working on some classes which I need to serialize/deserialize to xml, that can be used for configuration. Here is a sample of what I am trying to do
[Serializable]
public class MyConfig
{
[XmlElement]
public string ConfigOption { get; set; }
[XmlElement]
public Uri SomeUri { get; set; }
}
I want to override the way that the Uri property is being serialized. So when the serialize method is called, I want it to look like this
<MyConfig>
<ConfigOption></ConfigOption>
<SomeUri uri="" />
</MyConfig>
Is there a way to plug into .net serialization and override how all Uri objects are serialized and deserialized? Note that I dont want to create a class called MyUri and use that as the type of SomeUri, I just want to plug into the place where the serialized serializes types of Uri and override that behavior.