public static T FromStringConstant <T>(this string value) where T : struct { var option = typeof(T).GetTypeInfo() .DeclaredFields .FirstOrDefault( f => f.GetCustomAttributes( typeof(StringConstantAttribute), false) .Any(a => ((StringConstantAttribute)a).GetStringConstant() == value)); return(option == null ? EnumHelpers.Default <T>() : Enum <T> .Parse(option.Name)); }