示例#1
0
        public static void InitializeAddOnTypes()
        {
            List <Type> types = new List <Type>();

            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                Type[] exportedTypes = new Type[0];
                try { exportedTypes = assembly.GetExportedTypes(); }
                catch { }
                finally { types.AddRange(exportedTypes); }
            }

            AddOnTypes.Clear();
            AddOnTypes.AddRange(types
                                .Where(t => t.GetCustomAttribute <AddOnAttribute>() != null && t.IsClass && !t.IsAbstract)
                                .Where(t => t.GetInterface(typeof(IAddOn).FullName) != null));

            ProjectTypes.Clear();
            ProjectTypes.AddRange(types
                                  .Where(t => t.GetCustomAttribute <ProjectTypeAttribute>() != null && t.IsClass && !t.IsAbstract));
        }