I am trying to do deserialization IN SILVERLIGHT using c#. Before i was using XmlArray and it was working but i want to use List instead because i have done the previous part all using List (so looks odd when i use array just for it).
My xml is like:
<ps>
<disable_others>
<disable_other>
<disable_value>1</disable_value>
<to_disable>skew</to_disable>
<to_disable>skew_side</to_disable>
</disable_other>
<disable_other>
<disable_value>0</disable_value>
<to_disable>automodel</to_disable>
</disable_other>
</disable_others>
<ps>
And my trY to deserialize it is:
[XmlRoot(ElementName = "ps")]
public class ps
{
[XmlArray("disable_others")]
[XmlArrayItem("disable_other", IsNullable = false)]
public List<string> Disable_Others { get; set; }
/* I know it can be done using the below but i have to use List not array:
[XmlArray("disable_others")]
[XmlArrayItem("disable_other", IsNullable = false)]
public Disable_Other[] Disable_Others { get; set; } */
}
[XmlRoot(ElementName = "disable_Others")]
public class Disable_Others
{
[XmlElement("disable_other")]
public List<Disable_Other> Disable_Other { get; set; }
}
[XmlRoot(ElementName = "Disable_Other")]
public class Disable_Other
{
[XmlElement("disablingitem")]
public int DisablingItem { get; set; }
[XmlElement("to_disable")]
public string[] To_Disable { get; set; }
[XmlElement("disable_value")]
public byte Disable_Value { get; set; }
}
Could some one please help me achieving the target using List instead of array(XmlArray) ?
Enumerable.ToList()on the array? (Or is that too inefficient?)