2010-06-29 42 views
2
[XmlRoot("ConfigurationRoot")] 
public class XmlDBConfiguration 
{ 
    [XmlArray("Customers")] 
    [XmlArrayItem("Customer", typeof(Customer))] 

    public ArrayList _customers; 
    private Dictionary<string, Customer> _customerDictionary;} 

是否有可能從另一個靜態類或任何其他方式定義元素名稱(在我的情況下它是ConfigurationRoot)?我想定義我的類將被序列化(在我的情況下,它是客戶)以及。是否有可能在那裏放置一個變量,並在創建實例時更改它?定義XmlRoot並用變量對其進行輸入?

在此先感謝

回答

2

是的,你可以通過使用XmlSerializer構造函數,一個XmlAttributesOverrides對象做。明確支持提供您自己的XmlRootAttribute。這在MSDN Library topic中得到了很好的解釋。

相關問題