2
我有一个xsd文件,它具有以下定义。当使用xsd.exe
从xsd文件生成类时,enum attrs将获得其他FieldSpecified
属性,如下所示。除非设置了FieldSpecified
属性,否则该值不会与该属性的值序列化。是否有一个额外的属性,我可以添加到xsd或一个标志,我可以使用xsd.exe
始终使该值被序列化?从xsd
XSD的属性以防止XSD.exe字段指定的标志
示例:从生成码
<xs:simpleType name="adrLn">
<xs:restriction base="xs:string">
<xs:enumeration value="ST" />
<xs:enumeration value="APTN" />
</xs:restriction>
</xs:simpleType>
...
<xs:element name="AddressLine" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="AddrLineTypCd" type="adrLn" />
</xs:complexType>
</xs:element>
实施例:
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class RequestCheckIssueAddressAddressLine {
private adrLn addrLineTypCdField;
private bool addrLineTypCdFieldSpecified;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public adrLn AddrLineTypCd {
get {
return this.addrLineTypCdField;
}
set {
this.addrLineTypCdField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool AddrLineTypCdSpecified {
get {
return this.addrLineTypCdFieldSpecified;
}
set {
this.addrLineTypCdFieldSpecified = value;
}
}
}
我希望它会实现一个具有可空衬板或标志字段如果已经使用了setter,那么该字段是序列化的。发布后,我发现它也为数字值。 – QueueHammer