コード例 #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>
        /// 获取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;
        }