Beispiel #1
0
        /// <summary>
        /// 将反射对象放入插件目录字典
        /// </summary>
        /// <param name="pluginCategoryDictionary">插件目录字典</param>
        /// <param name="type">反射类型</param>
        /// <param name="strFilterObjectNameArray">插件目录字典</param>
        private void GetPluginObject(PluginCategoryDictionary pluginCategoryDictionary, Type type, string[] strFilterObjectNameArray, bool bFilterObjectNameArrayTypeRemove)
        {
            IPlugin pPlugin = null;

            try
            {
                pPlugin = Activator.CreateInstance(type) as IPlugin;
            }
            catch (Exception ex)
            {
                //LiuZhenHong.Controls.WFNew.Forms.TBMessageBox.Show("“" + type.FullName + "”反射生成对象时发生异常(" + ex.Message + ")");
                this.OnPluginReflection(
                    new PluginReflectionEventArgs(
                        PluginReflectionStyle.eCreateException, null, "“" + type.FullName + "”反射生成对象时发生异常(" + ex.Message + ")"));
            }
            finally
            {
                if (pPlugin != null)
                {
                    if (bFilterObjectNameArrayTypeRemove)
                    {
                        if (this.Contains(strFilterObjectNameArray, pPlugin.Name))
                        {
                            this.OnPluginReflection(new PluginReflectionEventArgs(PluginReflectionStyle.eExceptPluginObject, pPlugin, "排除的插件对象"));
                        }
                        else if (pluginCategoryDictionary.ContainsPlugin(pPlugin.Name))
                        {
                            this.OnPluginReflection(new PluginReflectionEventArgs(PluginReflectionStyle.eConflictPluginObject, pPlugin, "冲突的插件对象"));
                        }
                        else
                        {
                            pluginCategoryDictionary.AddPlugin(pPlugin);
                            this.OnPluginReflection(new PluginReflectionEventArgs(PluginReflectionStyle.eEfficientlyPluginObject, pPlugin, "创建有效地插件对象"));
                        }
                    }
                    else
                    {
                        if (this.Contains(strFilterObjectNameArray, pPlugin.Name))
                        {
                            pluginCategoryDictionary.AddPlugin(pPlugin);
                            this.OnPluginReflection(new PluginReflectionEventArgs(PluginReflectionStyle.eEfficientlyPluginObject, pPlugin, "创建有效地插件对象"));
                        }
                        else if (pluginCategoryDictionary.ContainsPlugin(pPlugin.Name))
                        {
                            this.OnPluginReflection(new PluginReflectionEventArgs(PluginReflectionStyle.eConflictPluginObject, pPlugin, "冲突的插件对象"));
                        }
                        else
                        {
                            this.OnPluginReflection(new PluginReflectionEventArgs(PluginReflectionStyle.eExceptPluginObject, pPlugin, "排除的插件对象"));
                        }
                    }
                }
            }
        }
        public PluginCategoryDictionary GetDifferent(PluginCategoryDictionary pluginCategoryDictionary)
        {
            if (pluginCategoryDictionary == null || pluginCategoryDictionary.Count == 0)
            {
                return(this);
            }
            //
            PluginCategoryDictionary pluginCategoryDictionaryDifferent = new PluginCategoryDictionary();

            foreach (PluginCategory one in this.m_PluginCategoryList)
            {
                foreach (IPlugin one2 in one.PluginCollection)
                {
                    if (one2 == null || pluginCategoryDictionary.ContainsPlugin(one2.Name))
                    {
                        continue;
                    }
                    //
                    pluginCategoryDictionaryDifferent.GetOrCreatePluginCategory(one2.CategoryIndex).PluginCollection.Add(one2);
                }
            }
            return(pluginCategoryDictionaryDifferent);
        }