I have an enum defined as
public enum velocityUom
{ /// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("m/s")]
ms,

/// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("cm/a")]
cma,
...
}

This class was generated by xsd.exe, from a schema like
<xsd:simpleType name="velocityUom">
<xsd:enumeration value="m/s"/>
<xsd:enumeration value="cm/a"/>
...
</xsd:restriction>
</xsd:simpleType>

I would like to retrieve the XmlEnumAttribute values for this Enum so that I
can create a combo box with values like "m/s", "cm/a", ... so that I don't
have to hard-code the XML-enum values in my code.

Is there any way to do this? the MSDN examples are only to add extra enum
values for a class and Enum.GetNames() just retrieves "ms", "cma", ...

Thanks,

Edward Clements

Re: retrieving the XmlEnumAttribute values for an Enum by Gaurav

Gaurav
Sun May 14 17:55:29 CDT 2006

> I would like to retrieve the XmlEnumAttribute values for this Enum so that
> I
> can create a combo box with values like "m/s", "cm/a", ... so that I don't
> have to hard-code the XML-enum values in my code.

Use reflection.

typeof(velocityUom).GetFields(...)
and then
FieldInfo.GetCustomAttribute(typeof(XmlEnum), ...)


--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://www.edujini.in
-------------------