Beispiel #1
0
        /// <summary>
        /// 导入插件配置文件
        /// </summary>
        /// <param name="plugfile">插件配置文件路径</param>
        public void LoadPlugin(string plugfile)
        {
            container = ZhyContainer.CreateUnity();
            plugin    = new PluginConfig();

            //switch (appType)
            //{
            //    case AppType.WCF:
            //        helper = new WcfFrame.ServerController.ControllerHelper();
            //        break;
            //}

            assemblyPath = new FileInfo(plugfile).Directory.FullName + "\\dll";

            var fileMap = new ExeConfigurationFileMap {
                ExeConfigFilename = plugfile
            };

            System.Configuration.Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);

            var plugininfo = (PluginSectionHandler)configuration.GetSection("plugin");

            if (plugininfo != null)
            {
                plugin.Load(plugininfo, plugfile);
            }

            LoadDllList(plugfile);//加载程序集

            var unitySection = (UnityConfigurationSection)configuration.GetSection("unity");

            if (unitySection != null)
            {
                container.LoadConfiguration(unitySection);//判断EntLib的路径对不对
            }
            if (plugin.defaultdbkey != "")
            {
                database = FactoryDatabase.GetDatabase(plugin.defaultdbkey);
            }
            else
            {
                database = FactoryDatabase.GetDatabase();
            }

            database.PluginName = plugin.name;

            if (plugin.defaultcachekey != "")
            {
                cache = ZhyContainer.CreateCache(plugin.defaultcachekey);
            }
            else
            {
                cache = ZhyContainer.CreateCache();
            }
        }
        /// <summary>
        /// 导入插件配置文件
        /// </summary>
        /// <param name="plugfile">插件配置文件路径</param>
        public void LoadPlugin(string plugfile)
        {
            container = ZhyContainer.CreateUnity();
            plugin    = new PluginConfig();

            var fileMap = new ExeConfigurationFileMap {
                ExeConfigFilename = plugfile
            };

            System.Configuration.Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);

            var plugininfo = (PluginSectionHandler)configuration.GetSection("plugin");

            if (plugininfo != null)
            {
                plugin.Load(plugininfo, plugfile);
            }

            DllList = LoadDllList(plugfile);//加载程序集

            var unitySection = (UnityConfigurationSection)configuration.GetSection("unity");

            if (unitySection != null)
            {
                container.LoadConfiguration(unitySection);//判断EntLib的路径对不对
            }
            if (plugin.defaultdbkey != "")
            {
                database = FactoryDatabase.GetDatabase(plugin.defaultdbkey);
            }
            else
            {
                database = FactoryDatabase.GetDatabase();
            }

            database.PluginName = plugin.name;

            if (plugin.defaultcachekey != "")
            {
                cache = ZhyContainer.CreateCache(plugin.defaultcachekey);
            }
            else
            {
                cache = ZhyContainer.CreateCache();
            }
        }