XSD For Class C # Enum

1

I'm generating a class with XSD.EXE from a schema. I am summarizing the posting only the part of the schema that generates the enum that I doubt.

<xs:simpleType name="TCodUfIBGE">
    <xs:annotation>
        <xs:documentation>Tipo Código da UF da tabela do IBGE</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
        <xs:whiteSpace value="preserve"/>
        <xs:enumeration value="11"/>
        <xs:enumeration value="12"/>
        <xs:enumeration value="13"/>
        <xs:enumeration value="14"/>
        <xs:enumeration value="15"/>
        <xs:enumeration value="16"/>
        <xs:enumeration value="17"/>
        <xs:enumeration value="21"/>
        <xs:enumeration value="22"/>
        <xs:enumeration value="23"/>
        <xs:enumeration value="24"/>
        <xs:enumeration value="25"/>
        <xs:enumeration value="26"/>
        <xs:enumeration value="27"/>
        <xs:enumeration value="28"/>
        <xs:enumeration value="29"/>
        <xs:enumeration value="31"/>
        <xs:enumeration value="32"/>
        <xs:enumeration value="33"/>
        <xs:enumeration value="35"/>
        <xs:enumeration value="41"/>
        <xs:enumeration value="42"/>
        <xs:enumeration value="43"/>
        <xs:enumeration value="50"/>
        <xs:enumeration value="51"/>
        <xs:enumeration value="52"/>
        <xs:enumeration value="53"/>
    </xs:restriction>
</xs:simpleType>

In class it's getting like this:

Note: Also summarized.

 public enum TCodUfIBGE
 {

    /// <remarks/>
    [System.Xml.Serialization.XmlEnumAttribute("11")]
    Item11,

    /// <remarks/>
    [System.Xml.Serialization.XmlEnumAttribute("12")]
    Item12,

    /// <remarks/>
    [System.Xml.Serialization.XmlEnumAttribute("13")]
    Item13,
 }

Example:

 /// <remarks/>
    [System.Xml.Serialization.XmlEnumAttribute("11")]
    Item11 = 11,

Or else:

public enum TipoPessoa
{
   [System.Xml.Serialization.XmlEnumAttribute("1")]
    Fisica = 1,
   [System.Xml.Serialization.XmlEnumAttribute("2")]
    Juridica = 2
}

EDIT: Is there any way to generate this class with the values for the defined enum items equal to those of the attribute?

Why in an actual application would this be absurd?

    
asked by anonymous 21.09.2016 / 16:41

1 answer

5

I solved the problem as follows. When opening schema in VS note some reference problems:

SomehowthisFileioPermissionproblemaffectsclassgenerationbyxsd(xsdxmldsig-core-schema_v1.01.xsdnfe_v3.10.xsd/c)

Toworkaroundtheproblemitisnecessarytodesbloquearthefileandremovethesomenteleiturapermission(Imadealltheshcemafiles)

Youcannowgeneratetheclassagain(xsdxmldsig-core-schema_v1.01.xsdnfe_v3.10.xsd/c)andyouwillseethatyoucandefinethetypesthatwerepreviouslynotrecognizedbytheimage:

Source:

    
22.09.2016 / 05:20