コード例 #1
0
        /// <summary>
        /// 获取当前加载的所有插件中指定类型的配置内容
        /// </summary>
        /// <param name="itemName">Theme子节点名字【即配置项】</param>
        /// <returns></returns>
        public XThemeItem[] GetConfigItems(string itemName)
        {
            List <XThemeItem> items = new List <XThemeItem>();

            if (_plugins == null || _plugins.Length == 0)
            {
                return(null);
            }
            foreach (Plugin plugin in _plugins)
            {
                XThemeItem item = plugin.GetConfigItem(itemName);
                if (item != null)
                {
                    items.Add(item);
                }
            }
            return(items.ToArray());
        }
コード例 #2
0
        /// <summary>
        /// 解析配置项
        /// </summary>
        /// <param name="pluginXml"></param>
        /// <param name="xThemeRoot"></param>
        /// <returns></returns>
        private static XThemeItem[] ParseThemeConfig(string pluginXml, XElement xThemeRoot)
        {
            if (xThemeRoot == null)
            {
                return(null);
            }
            string            pluginPath = Path.GetDirectoryName(pluginXml);
            List <XThemeItem> items      = new List <XThemeItem>();
            var xThemes = xThemeRoot.Elements();

            foreach (XElement ele in xThemes)
            {
                string name   = ele.Name.LocalName;
                string lingin = ele.Attribute("linkin").Value;
                if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(lingin))
                {
                    continue;
                }
                lingin = pluginPath + lingin;
                XThemeItem themeItem = new XThemeItem {
                    Name = name, Linkin = lingin
                };
                if (!string.IsNullOrWhiteSpace(lingin))
                {
                    string linkinfullname = Path.GetFullPath(lingin);
                    themeItem.LinkinFullname = linkinfullname;
                }
                else if (ele.HasElements)
                {
                    XElement content = ele.Elements().First();
                    themeItem.Content = content;
                }
                items.Add(themeItem);
            }
            return(items.ToArray());
        }