private static Object EnumValueOf(String value, Type enumType)
{
String[] names = Enum.GetNames(enumType);
foreach (String name in names)
{
if (StringValueOf((Enum)Enum.Parse(enumType, name)).Equals(value))
{
return Enum.Parse(enumType, name);
}
}
throw new ArgumentException("The string is not a description or value of the specified enum.");
}