Ejemplo n.º 1
0
        /// <summary>
        /// 读取指定name的配置信息
        /// </summary>
        /// <param name="name">配置名</param>
        /// <returns></returns>
        public PluginConfigInfo ReadPluginConfigInfo(string name)
        {
            if (Plugins == null)
            {
                using (var sr = new FileStream(ConfigPath, FileMode.Open))
                {
                    Plugins = XmlDeserialize <PluginsConfig>(sr) as PluginsConfig;
                }
            }
            var plugin = Plugins.Plugin.FirstOrDefault(m => m.Name.Contains(name));

            if (plugin != null)
            {
                var configInfoConverter = new TPluginConfigInfoConverter();
                var pluginConfigInfo    = configInfoConverter.ConvertToPluginConfigInfo(plugin);
                return(pluginConfigInfo);
            }
            return(null);
        }
Ejemplo n.º 2
0
        public List <PluginConfigInfo> ReadPluginConfigInfo()
        {
            if (Plugins == null)
            {
                using (var sr = new FileStream(ConfigPath, FileMode.Open))
                {
                    Plugins = XmlDeserialize <PluginsConfig>(sr) as PluginsConfig;
                }
            }
            var pluginConfigInfoList = new List <PluginConfigInfo>();

            foreach (var item in Plugins.Plugin)
            {
                var configInfoConverter = new TPluginConfigInfoConverter();
                var pluginConfigInfo    = configInfoConverter.ConvertToPluginConfigInfo(item);
                if (pluginConfigInfo != null)
                {
                    pluginConfigInfoList.Add(pluginConfigInfo);
                }
            }
            return(pluginConfigInfoList);
        }