public static TDocument DeserializeFromFile <TDocument>( Func <string, string, string, DateTimeOffset, Author, TDocument> documentFactory, string file, DirectoryInfo publishedDirectory, IYamlMarkdown yamlMarkdown) where TDocument : MarkdownDocument { LogTo.Trace("DeserializeFromFile(file: {0}, publishedDirectory: {1}, yamlMarkdown)", file, publishedDirectory); var relativeUri = GetRelativeUriFromFile(publishedDirectory, file); var markdownWithFrontMatter = File.ReadAllText(file); var document = Deserialize(documentFactory, relativeUri, markdownWithFrontMatter, yamlMarkdown); return(document); }
public static TDocument Deserialize <TDocument>( Func <string, string, string, DateTimeOffset, Author, TDocument> documentFactory, string relativeUri, string markdownWithFrontMatter, IYamlMarkdown yamlMarkdown) where TDocument : MarkdownDocument { LogTo.Trace("Deserialize<{0}>(documentFactory, relativeUri: {1}, markdownWithFrontMatter: {2}, yamlMarkdown)", typeof(TDocument), relativeUri, markdownWithFrontMatter); MarkdownMetadata metadata; string markdown; yamlMarkdown.Deserialize(markdownWithFrontMatter, out metadata, out markdown); var published = DateTimeOffset.Parse(metadata.Published); var timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(metadata.Author.TimeZoneId); var author = new Author(metadata.Author.Name, metadata.Author.Email, timeZoneInfo); var document = documentFactory(relativeUri, metadata.Title, markdown, published, author); return(document); }
// ReSharper disable once SuggestBaseTypeForParameter public PageRepository(IPageRepositorySettings settings, IBlogPostRepositorySettings blogPostRepositorySettings, IGitRepository gitRepository, IYamlMarkdown yamlMarkdown) : base(settings, gitRepository, yamlMarkdown) { _blogDirectory = Path.Combine(blogPostRepositorySettings.PublishedDirectory.FullName, blogPostRepositorySettings.BlogDirectoryName); }
public static Page DeserializeFromFile(string file, DirectoryInfo publishedDirectory, IYamlMarkdown yamlMarkdown) { return(MarkdownDocumentSerialization.DeserializeFromFile( (relativeUri, title, content, published, author) => new Page(relativeUri, title, content, published, author), file, publishedDirectory, yamlMarkdown)); }
public static Page TryDeserializeFromFile(string file, DirectoryInfo publishedDirectory, IYamlMarkdown yamlMarkdown) { LogTo.Trace("TryDeserializeFromFile(file: {0}, publishedDirectory: {1}, yamlMarkdown)", file, publishedDirectory.FullName); Page page; try { page = DeserializeFromFile(file, publishedDirectory, yamlMarkdown); LogTo.Debug("Deserialized {0}.", file); } catch (Exception exception) { LogTo.DebugException(string.Format("Error while deserializing {0}.\n\n{1}", file, exception), exception); page = null; } return(page); }
protected MarkdownDocumentRepository(IMarkdownDocumentRepositorySettings settings, IGitRepository gitRepository, IYamlMarkdown yamlMarkdown) : base(gitRepository, settings.PublishedDirectory) { YamlMarkdown = yamlMarkdown; }
internal static string Serialize(this MarkdownDocument markdownDocument, IYamlMarkdown yamlMarkdown) { return(yamlMarkdown.Serialize(new MarkdownMetadata(markdownDocument), markdownDocument.Content)); }
public BlogPostRepository(IBlogPostRepositorySettings settings, IGitRepository gitRepository, IYamlMarkdown yamlMarkdown) : base(settings, gitRepository, yamlMarkdown) { _blogDirectory = new DirectoryInfo(Path.Combine(settings.PublishedDirectory.FullName, settings.BlogDirectoryName)); }
public BlogPostSerializationSteps(GivenData given, ActualData actual, IYamlMarkdown yamlMarkdown) { _given = given; _actual = actual; _yamlMarkdown = yamlMarkdown; }
public static BlogPost Deserialize(string relativeUri, string markdownWithFrontMatter, IYamlMarkdown yamlMarkdown) { return(MarkdownDocumentSerialization.Deserialize( (rUri, title, content, published, author) => new BlogPost(rUri, title, content, published, author), relativeUri, markdownWithFrontMatter, yamlMarkdown)); }