public static TEnum Parse <TEnum>(int value) where TEnum : struct, IConvertible { if (!EnumUtilities.IsDefined <TEnum>(value)) { throw new System.ArgumentOutOfRangeException(); } return((TEnum)((object)value)); }
public static TEnum Parse <TEnum>(string value) where TEnum : struct, IConvertible { TEnum result = (TEnum)Enum.Parse(typeof(TEnum), value); if (!EnumUtilities.IsDefined <TEnum>(value)) { throw new System.ArgumentOutOfRangeException(); } return(result); }
public static bool TryParse <TEnum>(int value, out TEnum result) where TEnum : struct, IConvertible { if (EnumUtilities.IsDefined <TEnum>(value)) { result = (TEnum)((object)value); return(true); } else { result = default; return(false); } }
public static bool TryParse <TEnum>(string value, out TEnum result) where TEnum : struct, IConvertible { return(Enum.TryParse(value, out result) ? !EnumUtilities.IsDefined <TEnum>(value) : false); }