当前位置: 首页>>代码示例>>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;未经允许,请勿转载。