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