/// <summary>
/// Attempts to parse a string in to an enum value
/// </summary>
/// <typeparam name="T">Enum to convert to</typeparam>
/// <param name="stringEnum">string to Parse</param>
/// <param name="ignoreCase">if the string is exect enum value true should be used else false</param>
/// <returns>enum of type T</returns>
public static T EnumParse<T>(this string stringEnum, bool ignoreCase)
{
if (string.IsNullOrEmpty(stringEnum) )
{
throw new ArgumentNullException("stringEnum");
}
stringEnum = stringEnum.Trim();
if (stringEnum.Length == 0)
{
throw new ArgumentException("Must specify valid information for parsing in the string.", "stringEnum");
}
Type t = typeof (T);
if (!t.IsEnum)
{
throw new ArgumentException("Type provided must be an Enum.", "T");
}
T enumType = (T) Enum.Parse(t, stringEnum, ignoreCase);
return enumType;
}