本文整理汇总了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;
}
示例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);
}
示例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;
}