本文整理匯總了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;
}