本文整理汇总了C#中Page.SetHeaderSettings方法的典型用法代码示例。如果您正苦于以下问题:C# Page.SetHeaderSettings方法的具体用法?C# Page.SetHeaderSettings怎么用?C# Page.SetHeaderSettings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page
的用法示例。
在下文中一共展示了Page.SetHeaderSettings方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFileData
public static Page GetFileData(FileInfo file, SnowSettings snowSettings)
{
var rawPage = File.ReadAllText(file.FullName);
var fileNameMatches = FileNameRegex.Match(file.Name);
var rawSettings = string.Empty;
if (!fileNameMatches.Success)
{
file.Name.OutputIfDebug(" - Skipping file: ");
" - File does not match the format {slug}.(md|markdown)".OutputIfDebug();
return null;
}
var result = MarkdownFileParser.ParseDataFromFile(rawPage);
var settings = PostParser.ParseSettings(result.Header);
var slug = fileNameMatches.Groups["slug"].Value.ToUrlSlug();
/// if a 'date' property is found in markdown file header, that date will be used instead of the date in the file name
DateTime date = DateTime.Now;
if (settings.ContainsKey("date"))
DateTime.TryParse((string)settings["date"], out date);
var markdown = new Markdown();
var bodySerialized = markdown.Transform(result.Body);
var excerptSerialized = markdown.Transform(result.Excerpt ?? string.Empty);
var pageHeader = new Page
{
FileName = file.Name,
MarkdownHeader = rawSettings,
Content = bodySerialized,
ContentExcerpt = excerptSerialized,
Settings = settings,
Date = date,
Url = "/" + slug
};
pageHeader.SetSnowSettings(snowSettings);
pageHeader.SetHeaderSettings(settings);
return pageHeader;
}