public static string GetJSONDescription(this AreaType area) { //Using reflection to get the field info FieldInfo info = area.GetType().GetField(area.ToString()); //Get the Description Attributes JSONDescriptionAttribute[] attributes = (JSONDescriptionAttribute[])info.GetCustomAttributes(typeof(JSONDescriptionAttribute), false); //Only capture the description attribute if it is a concrete result (i.e. 1 entry) if (attributes.Length == 1) { return(attributes[0].Description); } else //Use the value for display if not concrete result { throw (new CustomAttributeFormatException("Missing JSON Description")); } }