In version 1 of my application I have an XML document that looks like this:
<settings>
<background>black</background>
</settings>
With an element that I serialize and deserialize like this:
[XmlElement("background")]
public string XMLbackground {
get { return backgroundcolor; }
set { backgroundcolor = value; }
}
But now in version 2 I want to add new sub-elements to the background element:
<settings>
<background>
<color>black</color>
<angle>62</angle>
</background>
</settings>
Which means the background element is no longer a string but a class.
[XmlElement("background")]
public BackgroundSettings background = new BackgroundSettings();
//...
public class BackgroundSettings
{
[XmlElement("color")]
public string XMLcolor {
get { return backgroundcolor; }
set { backgroundcolor = value; }
}
[XmlElement("angle")]
public string XMLangle {
get { return backgroundangle; }
set { backgroundangle = value; }
}
}
How do I continue to read the version 1 XML document with the same code that now creates and reads the version 2 format using standard .NET serialization markup?