/// <summary> /// 加载模块主方法 /// </summary> /// <param name="moduleinfo">模块信息</param> /// <returns></returns> public virtual bool LoadModule(ModuleInfo moduleinfo) { _ModuleFileName = moduleinfo.ModuleFile; _ModuleAssembly = moduleinfo.ModuleAssembly; string entry = GetModuleEntryNameSpace(_ModuleAssembly); if (string.Empty == entry) return false; Form form = (Form)_ModuleAssembly.CreateInstance(entry); _ModuleMainForm = null; if (form is IModuleBase) _ModuleMainForm = (IModuleBase)form; return _ModuleMainForm != null; }
/// <summary> /// 获取模块列表,转换为ModuleInfo集合. /// </summary> public virtual IList<ModuleInfo> GetModuleList() { try { string[] files = null; //模块文件(*.dll) IList<ModuleInfo> list = new List<ModuleInfo>(); if (Directory.Exists(MODULE_PATH)) files = Directory.GetFiles(MODULE_PATH, "*.dll"); foreach (string mod in files) { Assembly asm = null; try { //.net framework dll asm = Assembly.LoadFile(mod); } catch { continue; } ModuleID id = GetModuleID(asm); string name = GetCurrentModuleName(); if (id != ModuleID.None) { ModuleInfo m = new ModuleInfo(asm, id, name, mod); list.Add(m); } } SortModule(list); //模块排序. return list; } catch (Exception ex) { Msg.ShowException(ex); return null; } }