private static void ScanAssembly(Assembly assembly) { int amount = 0; // process all types (even private ones) Type[] types = assembly.GetTypes(); for (int i = 0; i < types.Length; i++) { Type t = types[i]; var exports = t.GetCustomAttributes(typeof(ExportAttribute), false); if (exports.Length == 1) { ExportAttribute export = exports[0] as ExportAttribute; _exports.Add(new ExportedType(export, t)); } amount++; } }
/// <summary> /// Initializes a new instance of the ExportedType struct. /// </summary> /// <param name="attribute">The attribute that specifies the export.</param> /// <param name="type">The type that is exported.</param> public ExportedType(ExportAttribute attribute, Type type) : this() { this.Attribute = attribute; this.Type = type; }