Monday, 14 July 2014

XSD enums to C# classes



As follow up to:


Classes generated from XSD does not work with XmlSerializer


I found that this is what failed:



/// <remarks/>
// [System.Xml.Serialization.XmlTextAttribute()]
[System.Xml.Serialization.XmlAttributeAttribute()]
public List44 Value {
get {
return this.valueField;
}
set {
this.valueField = value;
}
}


The outcommented XmlTextAttribute would not work, so i changed it to XmlAttributeAttribute.


However, when getting the Value from the property i get "Item01" instead of the Enum value "01"


List44 looks like this:



/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.18020")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://ift.tt/1oWGkri")]
public enum List44 {

/// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("01")]
Item01,

/// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("02")]
Item02,


How do i get the actual Enum value?


No comments:

Post a Comment