本文整理汇总了C#中HttpServer.GetEngine方法的典型用法代码示例。如果您正苦于以下问题:C# HttpServer.GetEngine方法的具体用法?C# HttpServer.GetEngine怎么用?C# HttpServer.GetEngine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpServer
的用法示例。
在下文中一共展示了HttpServer.GetEngine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPages
/// <summary>
/// Returns a list of pages, the key being the title of the page.
/// </summary>
/// <param name="server"></param>
/// <returns></returns>
private Dictionary<string, Page> GetPages(HttpServer server)
{
var result = new Dictionary<string, Page>();
var commonmark = server.GetEngine("md");
var titleRegex = new Regex(@"<h1>(?<name>.+?)<\/h1>", RegexOptions.Compiled);
var pageFiles = server.GetLocalFilesIn("/wiki/pages/");
foreach (var filePath in pageFiles)
{
var fileName = Path.GetFileName(filePath);
var name = Path.GetFileNameWithoutExtension(filePath);
var pageName = name;
var contents = commonmark.RenderFile(filePath);
// Name = First H1 header
var match = titleRegex.Match(contents);
if (match.Success)
pageName = match.Groups["name"].Value;
result[pageName] = new Page() { Title = pageName, FileName = name };
}
return result;
}
示例2: GetPageContents
/// <summary>
/// Returns the contents for the page at filePath, rendered with
/// CommonMark and with a TOC if applicable.
/// </summary>
/// <param name="server"></param>
/// <param name="filePath"></param>
/// <returns></returns>
private string GetPageContents(HttpServer server, string filePath)
{
var commonmark = server.GetEngine("md");
var contents = commonmark.RenderFile(filePath);
if (contents.Contains(_tocCheck))
{
var toc = this.GenerateTableOfContents(ref contents);
contents = contents.Replace(_tocCheck, toc);
}
return contents;
}