I'm trying to expand an XML config file containing colors for various things, currently it's looking like this.
<Colors>
<FooColor1>0x0BD000</FooColor1>
<FooColor2>0x11C711</FooColor2>
<FooColor3>0x224466</FooColor3>
<FooColor4>0xAA3333</FooColor4>
<FooColor5>0x886644</FooColor5>
</Colors>
These all come out as strings and everything works fine and dandy. The problem comes in here, As I said, I'm trying to expand the file, the new format will be like this
<Colors>
<DetailColors>
<FooColor1>0x0BD000</FooColor1>
<FooColor2>0x11C711</FooColor2>
<FooColor3>0x224466</FooColor3>
<FooColor4>0xAA3333</FooColor4>
<FooColor5>0x886644</FooColor5>
</DetailColors>
<GoalColors>
//Similar stuff, not actually in yet.
</GoalColors>
</Colors>
However, the serialization style that worked with a single level, doesn't seem to be able to handle the nesting.
[System.SerializableAttribute()]
public class GraphColors
{
public string FooColor1 { get; set; }
public string FooColor2 { get; set; }
public string FooColor3 { get; set; }
public string FooColor4 { get; set; }
public string FooColor5 { get; set; }
}
[System.SerializableAttribute()]
public class DetailColors
{
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public GraphColors ColorSchema { get; set; }
}
[System.SerializableAttribute()]
public class Colors
{
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
private DetailColors CombinedColors { get; set; }
public static GraphColors getColorsFromConfig()
{
return new XmlSerializer(Colors).Deserialize(path).CombinedColors.ColorSchema
}
}
This worked fine when there wasn't an intermediate object, but now that intermediate object gives a null value. Any help would be greatly appreciated.