using System; using System.ComponentModel; using System.Linq; namespace Pinwheel.Extensions { public static class AwardExtensions { public static string GetNameFromAttribute(this Type type) { var attrib = type.GetAttribute(); return attrib == null ? type.Name : attrib.DisplayName; } public static string GetDescriptionFromAttribute(this Type type) { var attrib = type.GetAttribute(); return attrib == null ? "[ No Description Provided ]" : attrib.Description; } public static T GetAttribute(this Type type) where T : Attribute { var attributes = from a in type.GetCustomAttributes(typeof(T), false) select a; return (T)attributes.SingleOrDefault(); } } }