How to handle enumerations?

Jul 20, 2009 at 12:20 AM
Edited Jul 20, 2009 at 12:22 AM

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?