How to handle enumerations?

Jul 19, 2009 at 11:20 PM
Edited Jul 19, 2009 at 11:22 PM

Here is an extremely simple snippet from a schema.

<xsd:simpleType name="TransResponseCodeType">
  <xsd:restriction base="xsd:normalizedString">
   <xsd:enumeration value="Always"/>
   <xsd:enumeration value="OnError"/>
  </xsd:restriction>
 </xsd:simpleType>

Here is the corresponding code that was generated to represent this schema element.

  [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3074")]
  [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.wbf.org/xml/B2MML-V0401")]
  public enum TransResponseCodeType
  {

    /// <remarks/>
    Always,

    /// <remarks/>
    OnError,
  }

The problem occurs when trying to use this code to programatically populate the value.  The object generated in code requires the value to be an Integer, but the actual valid values are the literal String values "Always" or "OnError".  Is there a solution that will allow the object value to be populated programatically using the generated code?