0
我做一個服務,在XML返回數據的集成。 我反序列化他們到使用XML序列化的數據列表:環路上的屬性值泛型列表<T>
[Serializable, XmlRoot("string", Namespace = "http://tempuri.org/", IsNullable = true)]
public class PositionPosting
{
[XmlArray("JobCategories")]
[XmlArrayItem("JobCategory", typeof(ExportItems))]
public ExportItems[] JobCategory { get; set; }
}
[Serializable()]
public class ExportItems
{
[XmlAttribute("key")]
public string Key { get; set; }
[XmlAttribute("text")]
public string Value { get; set; }
}
至於結果,我有這樣的:
我提供GetServiceData方法有什麼需要序列化到XML模型。
在此之後我創建將得到這個列表就像IList的方法:
private void UpdateDropDown<T>(IList<DropDownModel> model, IList<T> syncData) where T : class
?我怎樣才能從JobCategories陣列中的IList syncData屬性和名稱?
感謝您的幫助!
參數'syncData'只是與class'的'唯一約束T'的'泛型集合,所以從理論上講,所有你需要做的就是將結果轉換到'名單'對象,並通過他們在這樣肯定? 編輯:如果結構是一個數組,使用'System.Linq'將允許你調用'ToList()'。 –
Richard
2012-03-23 10:57:09
你可以寫一個例子,因爲我不知道我理解你... – 2012-03-23 11:14:42