示例#1
0
 public void AddModule(BuilderModuleInfo module)
 {
     if (module == null)
     {
         return;
     }
     this._modules.Add(module.Instantiate());
 }
示例#2
0
        static BuilderModule()
        {
            _modulesByName = new Dictionary <string, BuilderModuleInfo>();
            _modulesByGuid = new Dictionary <string, BuilderModuleInfo>();

            foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
            {
                if (a.GlobalAssemblyCache)
                {
                    continue;
                }

                Type[] types;
                try
                {
                    types = a.GetTypes();
                }
                catch (ReflectionTypeLoadException ex)
                {
                    types = ex.Types;
                }

                if (types != null)
                {
                    foreach (var t in types)
                    {
                        if (t == null)
                        {
                            continue;
                        }
                        if (typeof(BuilderModule).IsAssignableFrom(t) && t.IsPublic && !t.IsAbstract)
                        {
                            var attrs = t.GetCustomAttributes(typeof(BrowsableAttribute), true);
                            if (attrs.Length > 0 && !((BrowsableAttribute)attrs[0]).Browsable)
                            {
                                continue;
                            }

                            var info = new BuilderModuleInfo(t);
                            _modulesByName[t.FullName] = new BuilderModuleInfo(t);
                            if (info.guid != null)
                            {
                                _modulesByGuid[info.guid] = info;
                            }
                        }
                    }
                }
            }
        }