Esempio n. 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);
        }
Esempio n. 2
0
 private string RenderText(HttpCache cache, Dictionary <string, HttpContent> baseContent)
 {
     return(StringHelper.GetString(Render(cache, baseContent)));
 }
Esempio n. 3
0
 public byte[] Render(HttpCache cache)
 {
     return((this.ParsingRequired) ? Render(cache, baseContent) : this.content);
 }
Esempio n. 4
0
 private string RenderText(HttpCache cache, Dictionary<string, HttpContent> baseContent)
 {
     return StringHelper.GetString(Render(cache, baseContent));
 }
Esempio n. 5
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;
        }
Esempio n. 6
0
        private static HttpContent Read(HttpCache cache, string request, Dictionary<string, HttpContent> baseContent)
        {
            request = request.TrimWhiteSpace().Replace(@"/", @"\").ToLower();

            if (cache.Contains(request))
            {
                return new HttpContent(cache.Get(request));
            }
            else
            {
                throw new FileNotFoundException("did not find " + request);
            }
        }
Esempio n. 7
0
 public byte[] Render(HttpCache cache)
 {
     return (this.ParsingRequired) ? Render(cache, baseContent) : this.content;
 }