Beispiel #1
0
        private byte[] Render(HttpCache cache, Dictionary <string, HttpContent> baseContent)
        {
            if (this.ContentType.Contains("text") || this.ContentType.Contains("xml"))
            {
                string text = Encoding.ASCII.GetString(this.content);

                // include linked externals
                MatchCollection matches = Regex.Matches(text, INCLUDE_RENDER_SYNTAX);
                if (matches.Count > 0)
                {
                    foreach (Match match in matches)
                    {
                        string key = match.Groups[1].Value.TrimWhiteSpace();
                        string replacmentContent = HttpContent.Read(cache, key, baseContent).RenderText(cache, baseContent);
                        text = Regex.Replace(text, match.Groups[0].Value, replacmentContent);
                    }
                }

                // include linked externals
                matches = Regex.Matches(text, CONTENT_RENDER_SYNTAX);
                if (matches.Count > 0)
                {
                    foreach (Match match in matches)
                    {
                        string key = match.Groups[1].Value.TrimWhiteSpace();
                        if (baseContent.ContainsKey(key))
                        {
                            HttpContent replacmentContent = baseContent[key];
                            text = Regex.Replace(text, match.Groups[0].Value, replacmentContent.RenderText(cache, baseContent));
                        }
                    }
                }

                return(Encoding.ASCII.GetBytes(text));
            }

            return(this.content);
        }
Beispiel #2
0
 private string RenderText(HttpCache cache, Dictionary <string, HttpContent> baseContent)
 {
     return(StringHelper.GetString(Render(cache, baseContent)));
 }
Beispiel #3
0
 public byte[] Render(HttpCache cache)
 {
     return((this.ParsingRequired) ? Render(cache, baseContent) : this.content);
 }