Beispiel #1
0
        /// <summary>
        /// 解析包含标签
        /// </summary>
        /// <param name="label">包含标签</param>
        /// <param name="rootTemplate">当前站的模板方案根目录</param>
        /// <returns></returns>
        public string ParseInclude(IncludeLabel label, string rootTemplate)
        {
            string resultContent;       // 解析后的内容
            string filePath;

            filePath      = rootTemplate + label.FilePath;
            resultContent = string.Empty;

            if (File.Exists(filePath))
            {
                resultContent = File.ReadAllText(filePath);
            }

            return(resultContent);
        }
Beispiel #2
0
        /// <summary>
        /// 抓取所有包含标签
        /// </summary>
        /// <param name="templateContent">模板内容</param>
        /// <returns> 模板内容中的包含标签 key 标签内容 value   包含的文件路径</returns>
        public List <IncludeLabel> GetIncludeLabel(string templateContent)
        {
            List <IncludeLabel> lstIncludeLabel; // 模板内容中的包含标签 key 标签内容 value   包含的文件路径
            Regex           reg;
            MatchCollection matchCollection;
            IncludeLabel    includeLabel;

            includeLabel    = new IncludeLabel();
            reg             = new Regex(@"\{Include\s+FilePath\s*=\s*[""'](?<1>[^""']+)[""']\s*\}", RegexOptions.Singleline | RegexOptions.IgnoreCase);
            lstIncludeLabel = new List <IncludeLabel>();

            matchCollection = reg.Matches(templateContent);

            foreach (Match matchItem in matchCollection)
            {
                includeLabel.Content  = matchItem.Value;
                includeLabel.FilePath = matchItem.Groups[1].Value;
                lstIncludeLabel.Add(includeLabel);
            }

            return(lstIncludeLabel);
        }