private bool LoadModule(string moduleName) { try { string facadeClass = "PAT." + moduleName + ".ModuleFacade"; string file = (new FileInfo("PAT.Module." + moduleName + ".dll")).FullName; Assembly assembly = Assembly.LoadFrom(file); CurrentModule = (ModuleFacadeBase)assembly.CreateInstance( facadeClass, true, BindingFlags.CreateInstance, null, null, null, null); if (CurrentModule.GetType().Namespace != "PAT." + moduleName) { CurrentModule = null; return false; } CurrentModule.ReadConfiguration(); return true; } catch { } return false; }
private bool LoadModule(string moduleName) { bool ret = false; do { try { if (Common.Utility.Utilities.ModuleDictionary.ContainsKey(moduleName)) { if (mModule == null || moduleName != mModule.ModuleName) mModule = Common.Utility.Utilities.ModuleDictionary[moduleName]; ret = true; break; } string facadeClass = "PAT." + moduleName + ".ModuleFacade"; string file = Path.Combine(Path.Combine(Common.Utility.Utilities.ModuleFolderPath, moduleName), "PAT.Module." + moduleName + ".dll"); Assembly assembly = Assembly.LoadFrom(file); mModule = (ModuleFacadeBase)assembly.CreateInstance(facadeClass, true, BindingFlags.CreateInstance, null, null, null, null); if (mModule.GetType().Namespace != "PAT." + moduleName) { mModule = null; break; } //CurrentModule.ShowModel += new ShowModelHandler(ShowModel); //CurrentModule.ExampleMenualToolbarInitialize(this.MenuButton_Examples); mModule.ReadConfiguration(); ret = true; } catch { } } while (false); return ret; }
private bool createModule() { bool ret = false; do { string moduleName = "KWSN Model"; if (mModule != null && mModule.ModuleName == moduleName) break; string facadeClass = "PAT." + moduleName + ".ModuleFacade"; string file = Path.Combine(Path.Combine(Utilities.ModuleFolderPath, moduleName), "PAT.Module." + moduleName + ".dll"); Assembly assembly = Assembly.LoadFrom(file); mModule = (ModuleFacadeBase)assembly.CreateInstance( facadeClass, true, BindingFlags.CreateInstance, null, null, null, null); if (mModule.GetType().Namespace != "PAT." + moduleName) { mModule = null; break; } // mModule.ShowModel += new ShowModelHandler(ShowModel); // mModule.ExampleMenualToolbarInitialize(this.MenuButton_Examples); mModule.ReadConfiguration(); ret = true; } while (false); return ret; }