Exemple #1
0
 public void AppendModuleCall(ModuleNode module, ModuleCall call)
 {
     lock (module_table) {
         module.ModuleCallTable.Add(call);
         module_call_count++;
     }
 }
Exemple #2
0
 public void Del(ModuleNode module)
 {
     try {
         object[] tmp = new object[] { };
         module.Invoke(typeof(IModule).FullName, SModule.FINAL, ref tmp);
     } catch (Exception) {
         //log4net.ILog log = log4net.LogManager.GetLogger(typeof(ModuleCtl));
         //log.Error("Exception of invoking module final method.", ex);
     } finally {
         module.UnLoad();
         module_table.Remove(module);
     }
 }
Exemple #3
0
        // Self Methods ===============================================================
        private void AtModuleLoad(string filePath)
        {
            ModuleNode module = new ModuleNode();

            try {
                module.Load(filePath);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message, "Error");
                return;
            }

            try {
                module.Invoke(SModule.FULL_NAME, SModule.INIT, null);
            }
            catch (Exception ex) {
                module.UnLoad();
                MessageBox.Show(ex.Message, "Error");
                return;
            }

            // 加载模块已经成功
            FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(filePath);
            ModuleUnit moduleUnit = new ModuleUnit();
            moduleUnit.ID = (string)module.Invoke(SModule.FULL_NAME, SModule.GET_MODULE_ID, null);
            moduleUnit.Name = fvi.ProductName;
            moduleUnit.TermInfo = (string)module.Invoke(SModule.FULL_NAME, SModule.GET_MODULE_INFO, null);
            moduleUnit.State = SockState.Closed;
            moduleUnit.FilePath = filePath;
            moduleUnit.FileName = module.AssemblyName;
            moduleUnit.FileComment = fvi.Comments;
            moduleUnit.Module = module;

            // 加入 table
            rwlock.AcquireWriterLock(-1);
            moduleTable.Add(moduleUnit);
            rwlock.ReleaseWriterLock();
        }
Exemple #4
0
        public ModuleNode Add(string filePath)
        {
            ModuleNode module = new ModuleNode();
            module.Load(filePath);

            if (!module.CheckInterface(new string[] { typeof(IModule).FullName })) {
                module.UnLoad();
                throw new ApplicationException(
                    String.Format("Can't find {0} in specified assembly {1}", typeof(IModule).FullName, filePath));
            }

            try {
                object[] tmp = new object[] {};
                module.Invoke(typeof(IModule).FullName, SModule.INIT, ref tmp);
                module.ModuleID = (string)module.Invoke(typeof(IModule).FullName, SModule.GET_MODULE_ID, ref tmp);
            } catch (Exception) {
                module.UnLoad();
                throw;
            }

            module_table.Add(module);
            return module;
        }