I have a settings object which I serialize to disk. When my application loads, it deserialises the object then uses it.
Let's say I have one XML file (the primary file) which is complete and I have a subset XML document which is incomplete. If I wanted to overwrite the primary with whatever the subset had and return a complete XML document which can be deserialized, how would I do that?
For a concrete example, let's say my settings class looks like this:
public class MySettings {
public string DateFormat { get; set; }
public bool SendSMS { get; set; }
public AddressSettings AddressSettings { get; set; }
}
public class AddressSettings {
public bool ShowPostCode { get; set; }
}
And the primary serialized XML looks like this:
<MySettings>
<DateFormat>mm/DD/yyyy</DateFormat>
<SendSMS>False</SendSMS>
<AddressSettings>
<ShowPostCode>True</ShowPostCode>
</AddressSettings>
</MySettings>
And the subset XML looks like this:
<MySettings>
<AddressSettings>
<ShowPostCode>False</ShowPostCode>
</AddressSettings>
</MySettings>
The result XML should look like this:
<MySettings>
<DateFormat>mm/DD/yyyyM</DateFormat>
<SendSMS>False</SendSMS>
<AddressSettings>
<ShowPostCode>False</ShowPostCode>
</AddressSettings>
</MySettings>
How do I do that concisely in C#?