Ejemplo n.º 1
0
        /// <summary>
        /// 加载插件模块
        /// </summary>
        /// <param name="plugPath">插件路径</param>
        /// <param name="paras">初始化参数</param>
        /// <returns>模块对象</returns>
        internal static List <ModuleBaseEntry> LoadPlugModule(string plugPath, DelegateAppSelfMessageNotic delegateAction, params object[] paras)
        {
            List <ModuleBaseEntry> modules = new List <ModuleBaseEntry>();

            try
            {
                List <Assembly> assemblyList = GetAllAssemblies(plugPath);

                foreach (var item in assemblyList)
                {
                    Type[] types = item.GetTypes();
                    foreach (var t in types)
                    {
                        if (IsEEMSModule(t))
                        {
                            ModuleBaseEntry plugPanel = (ModuleBaseEntry)Activator.CreateInstance(t, paras);
                            plugPanel.SelfMessageNotic = delegateAction;
                            modules.Add(plugPanel);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                LogHelper.Instance.WirteErrorMsg("Module Init:" + e.Message);
            }

            modules.Sort();

            return(modules);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 模块间信息转换
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void ModulesSelfMessageNotic(object sender, SelfMessageEventArgs e)
        {
            ModuleBaseEntry        moduleBase = sender as ModuleBaseEntry;
            List <ModuleBaseEntry> moduleList = Modules.FindAll(p => !p.ModuleCode.Equals(moduleBase.ModuleCode));

            if (moduleList.Count > 0)
            {
                moduleList.ForEach(p => p.AppSelfMessageNotic(sender, e));
            }

            if (!EventManager.Instance.ModuleCode.Equals(moduleBase.ModuleCode))
            {
                EventManager.Instance.AppSelfMessageNotic(sender, e);
            }
        }