public static string GetName(this AchievementsReworked value) { var fieldInfo = value.GetType().GetField(value.ToString()); var descriptionAttributes = fieldInfo.GetCustomAttributes( typeof(DisplayAttribute), false) as DisplayAttribute[]; if (descriptionAttributes == null) { return(string.Empty); } return((descriptionAttributes.Length > 0) ? descriptionAttributes[0].Name : value.ToString()); }
public static string GetDescription(this AchievementsReworked value) { FieldInfo fi = value.GetType().GetField(value.ToString()); DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes( typeof(DescriptionAttribute), false); if (attributes != null && attributes.Length > 0) { return(attributes[0].Description); } else { return(value.ToString()); } }