我有這個類,我想序列化爲一個XML文件。我想爲類的每個屬性添加一個「Description」屬性,如下所示。可能嗎?或者我怎麼能做到這一點?如何在設計時爲每個類的每個XMLElement定義一個「描述」
[Serializable]
public class Arm : INotifyPropertyChanged{
private int _ID;
private ArmStore _aStore;
private ArmDimension _dimension;
private Zone _accessibleZone;
[XmlElement("ID")]
[XmlAttribute("description"), Value="It defines ID number of the Arm"]
public int ID {
get { return _ID; }
set { _ID = value; }
}
[XmlElement("Store")]
[XmlAttribute("description"), Value="It defines the Store of the Arm"]
public ArmStore aStore {
get { return _aStore; }
set {
_aStore = value;
Notify("aStore");
}
}
[XmlElement("Dimension")]
[XmlAttribute("description"), Value="It defines the dimension of the Arm"]
public ArmDimension dimension {
get { return _dimension; }
set {
_dimension = value;
Notify("dimension");
}
}
我想有以下結果:提前
<ID description="It defines ID number of the Arm">1</ID>
<Dimension description="It defines the dimension of the Arm">
<XMin>-150</XMin>
<XMax>150</XMax>
<YMin>-300</YMin>
<YMax>300</YMax>
</Dimension>
謝謝!