public static String GetDisplayName(Type type) { var attrs = type.GetCustomAttributes(typeof(ResourceIDAttribute), true); ResourceIDAttribute attr = attrs.First() as ResourceIDAttribute; return(attr.DisplayName); }
static ReaderCollector() { Assembly assembly = typeof(ResourceReaderBase).Assembly; var query = from item in assembly.GetTypes() where typeof(ResourceReaderBase).IsAssignableFrom(item) && (item.Attributes & TypeAttributes.Abstract) != TypeAttributes.Abstract select item; readers = new Dictionary <String, Type>(query.Count()); foreach (var item in query) { var attrs = item.GetCustomAttributes(typeof(ResourceIDAttribute), true); if (attrs.Length == 0) { continue; } ResourceIDAttribute attr = attrs.First() as ResourceIDAttribute; readers.Add(attr.ID, item); } }