代码之家  ›  专栏  ›  技术社区  ›  Kubi

用变量定义XmlRoot和typeof?

  •  2
  • Kubi  · 技术社区  · 14 年前
    [XmlRoot("ConfigurationRoot")]
    public class XmlDBConfiguration
    {
        [XmlArray("Customers")]
        [XmlArrayItem("Customer", typeof(Customer))]
    
        public ArrayList _customers;
        private Dictionary<string, Customer> _customerDictionary;}
    

    提前谢谢

    2 回复  |  直到 14 年前
        2
  •  2
  •   Hans Passant    14 年前

    是的,您可以通过使用接受XMLAttributeOverrides对象的XmlSerializer构造函数来实现这一点。明确支持提供自己的XmlRootAttribute。这一切在报告中都解释得很清楚 MSDN Library topic .