當前位置: 首頁>>代碼示例>>C#>>正文


C# ViewLocationResult.Contents方法代碼示例

本文整理匯總了C#中Nancy.ViewEngines.ViewLocationResult.Contents方法的典型用法代碼示例。如果您正苦於以下問題:C# ViewLocationResult.Contents方法的具體用法?C# ViewLocationResult.Contents怎麽用?C# ViewLocationResult.Contents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nancy.ViewEngines.ViewLocationResult的用法示例。


在下文中一共展示了ViewLocationResult.Contents方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RenderView

        public Response RenderView(ViewLocationResult viewLocationResult, dynamic model, IRenderContext renderContext)
        {
            var response = new HtmlResponse();

            var html = renderContext.ViewCache.GetOrAdd(viewLocationResult, result =>
                                                                                {
                                                                                    string markDown =
                                                                                        viewLocationResult.Contents()
                                                                                                          .ReadToEnd();


                                                                                    var parser = new Markdown();
                                                                                    return parser.Transform(markDown);
                                                                                });


            var serverHtml = ParagraphSubstitution.Replace(html, "$1");

            var renderHtml = this.engineWrapper.Render(serverHtml, model, new MarkdownViewEngineHost(new NancyViewEngineHost(renderContext), renderContext));

            response.Contents = stream =>
            {
                var writer = new StreamWriter(stream);
                writer.Write(renderHtml);
                writer.Flush();
            };

            return response;
        }
開發者ID:jchannon,項目名稱:Nancy.ViewEngines.Markdown,代碼行數:29,代碼來源:MarkDownEngine.cs

示例2: ConvertMarkdown

        public string ConvertMarkdown(ViewLocationResult viewLocationResult)
        {
            var content = viewLocationResult.Contents().ReadToEnd();

            // Parse out the post settings 
            var startOfSettingsIndex = content.IndexOf("---", StringComparison.InvariantCultureIgnoreCase);

            if (startOfSettingsIndex >= 0)
            {
                var endOfSettingsIndex = content.IndexOf(
                    "---", startOfSettingsIndex + 3, StringComparison.InvariantCultureIgnoreCase);

                endOfSettingsIndex += 3;
                content = content.Substring(endOfSettingsIndex, content.Length - endOfSettingsIndex);
            }

            return new Markdown().Transform(content);
        }
開發者ID:jchannon,項目名稱:Sandra.Snow,代碼行數:18,代碼來源:CustomMarkdownViewEngine.cs

示例3: RenderView

        public Response RenderView(ViewLocationResult viewLocationResult, dynamic model, IRenderContext renderContext)
        {
            var response = new HtmlResponse();

            string HTML = renderContext.ViewCache.GetOrAdd(viewLocationResult, result =>
	         {
	             string markDown = viewLocationResult.Contents().ReadToEnd ();
	             var parser = new MarkdownSharp.Markdown();
	             return parser.Transform(markDown);
	         });
            response.Contents = stream =>
            {
                var writer = new StreamWriter(stream);
                writer.Write(HTML);
                writer.Flush();
            };

            return response;
        }
開發者ID:dotnetcurry,項目名稱:Nancy.ViewEngines.Markdown,代碼行數:19,代碼來源:MarkDownEngine.cs


注:本文中的Nancy.ViewEngines.ViewLocationResult.Contents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。