private static T[] GetAttributes <T>(this ProjectState state) { FieldInfo fieldInfo = state.GetType().GetField(state.ToString()); object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(T), false); return(customAttributes.Cast <T>().ToArray()); }
public static string ToDescriptionString(this ProjectState val) { DescriptionAttribute[] attributes = (DescriptionAttribute[])val .GetType() .GetField(val.ToString()) .GetCustomAttributes(typeof(DescriptionAttribute), false); return(attributes.Length > 0 ? attributes[0].Description : string.Empty); }