コード例 #1
0
        /// <summary>
        /// 获取Css文件配置config
        /// </summary>
        /// <returns></returns>
        public static List<CSSGroupInfo> BuildCssGroupInfoList(out bool enableOptimizations)
        {
            if (!File.Exists(CSS_CONFIG_PATH))
            {
                throw new FileNotFoundException(string.Format("未找到配置文件:{0}!", CSS_CONFIG_PATH));
            }

            List<CSSGroupInfo> resultList = new List<CSSGroupInfo>();

            XmlHelper xmlHelper = new XmlHelper();
            xmlHelper.LoadXml(CSS_CONFIG_PATH);

            enableOptimizations = (xmlHelper.GetRootAttribute("enableOptimizations").ToLower() == "true" ? true : false);

            var getGroupList = xmlHelper.GetElements("Group");
            if (null != getGroupList && getGroupList.Count > 0)
            {
                getGroupList.ForEach(g =>
                {
                    string getVirtualPath = (g.Attribute("virtualPath") == null ? string.Empty : g.Attribute("virtualPath").Value);
                    string getName = g.Attribute("name").Value;

                    CSSGroupInfo newGroupInfo = new CSSGroupInfo() { Name = getName };
                    var getCssList = xmlHelper.GetElements(g, "Css");
                    if (null != getCssList && getCssList.Count > 0)
                    {
                        getCssList.ForEach(c =>
                        {
                            newGroupInfo.CSSPathList.Add(c.Value.Trim());

                        });
                    }
                    string defautVirtualPath = newGroupInfo.CSSPathList[0].Substring(0, newGroupInfo.CSSPathList[0].LastIndexOf('/')) + "/Css";
                    newGroupInfo.VirtualPath = (string.IsNullOrEmpty(getVirtualPath) ? defautVirtualPath : getVirtualPath);
                    resultList.Add(newGroupInfo);
                });
            }
            return resultList;
        }
コード例 #2
0
 /// <summary>
 /// 获取view-name映射配置config
 /// </summary>
 /// <returns></returns>
 public static List<ViewAliasInfo> BuildViewAliasInfoList()
 {
     if (!File.Exists(VIEW_ALIAS_PATH))
     {
         throw new FileNotFoundException(string.Format("未找到配置文件:{0}!", VIEW_ALIAS_PATH));
     }
     List<ViewAliasInfo> returnList = new List<ViewAliasInfo>();
     XmlHelper xmlHelper = new XmlHelper();
     xmlHelper.LoadXml(VIEW_ALIAS_PATH);
     var getList = xmlHelper.GetElements("add");
     if (null != getList && getList.Count > 0)
     {
         getList.ForEach(x =>
         {
             returnList.Add(new ViewAliasInfo() { Name = x.Attribute("name").Value, Path = x.Value.Trim() });
         });
     }
     return returnList;
 }
コード例 #3
0
        /// <summary>
        /// 获取ViewCss隐射关系config
        /// </summary>
        /// <returns></returns>
        public static List<ViewCSSMappingInfo> BuildViewCssMappingList()
        {
            if (!File.Exists(VIEW_CSS_MAPPING_PATH))
            {
                throw new FileNotFoundException(string.Format("未找到配置文件:{0}!", VIEW_CSS_MAPPING_PATH));
            }
            List<ViewCSSMappingInfo> returnList = new List<ViewCSSMappingInfo>();
            XmlHelper xmlHelper = new XmlHelper();
            xmlHelper.LoadXml(VIEW_CSS_MAPPING_PATH);
            var getList = xmlHelper.GetElements("Mapping");
            if (null != getList && getList.Count > 0)
            {
                getList.ForEach(m =>
                {
                    ViewCSSMappingInfo newInfo = new ViewCSSMappingInfo();
                    var getGroupList = xmlHelper.GetElements(xmlHelper.GetElement(m, "CssGroups"), "Group");
                    if (null != getGroupList && getGroupList.Count > 0)
                    {
                        getGroupList.ForEach(g =>
                        {
                            newInfo.CSSGroupNameList.Add(g.Value.Trim());
                        });
                    }
                    var getViewNameList = xmlHelper.GetElements(xmlHelper.GetElement(m, "ViewList"), "View");
                    if (null != getViewNameList && getViewNameList.Count > 0)
                    {
                        getViewNameList.ForEach(v =>
                        {
                            newInfo.ViewNameList.Add(v.Value.Trim());
                        });
                    }
                    returnList.Add(newInfo);

                });
            }
            return returnList;
        }