public Enum ReadEnumerated(string fieldName, System.Type enumType)
{
Enum value = (Enum)Enum.GetValues(enumType).GetValue(0);
if (BeginField(fieldName, true))
{
string xml = ReadString();
if (!String.IsNullOrEmpty(xml))
{
int index = xml.LastIndexOf('_');
if (index != -1)
{
int numericValue = Convert.ToInt32(xml.Substring(index + 1), CultureInfo.InvariantCulture);
value = (Enum)Enum.ToObject(enumType, numericValue);
}
else
{
value = (Enum)Enum.Parse(enumType, xml, false);
}
}
EndField(fieldName);
}
return value;
}