我希望我的枚举类具有名称-值对。我必须在我的 xsd 中定义枚举。
例如:目前我的 xsd 为
<xsd:simpleType name="ColorCode">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Red"/>
<xsd:enumeration value="Orange"/>
<xsd:enumeration value="LightGreen"/>
<xsd:enumeration value="DarkGreen"/>
<xsd:enumeration value="LightBlue"/>
<xsd:enumeration value="DarkBlue"/>
<xsd:enumeration value="DarkGrey"/>
<xsd:enumeration value="LightGrey"/>
</xsd:restriction>
</xsd:simpleType>
生成的代码是:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
public enum ColorCode {
/// <remarks/>
Red,
/// <remarks/>
Orange,
/// <remarks/>
LightGreen,
/// <remarks/>
DarkGreen,
/// <remarks/>
LightBlue,
/// <remarks/>
DarkBlue,
/// <remarks/>
DarkGrey,
/// <remarks/>
LightGrey,
}
如何定义我的 xsd 以便生成的代码如下所示:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
public enum ColorCode {
/// <remarks/>
Red = 0x12,
/// <remarks/>
Orange = 0x13,
/// <remarks/>
LightGreen = 0x17,
/// <remarks/>
DarkGreen=0x20,
/// <remarks/>
LightBlue=0x40,
/// <remarks/>
DarkBlue=0x50,
/// <remarks/>
DarkGrey0x90,
/// <remarks/>
LightGrey=0x190,
}