Class FileInfoExtensions
- Namespace
- Songhay.Publications.Extensions
- Assembly
- Songhay.Publications.dll
Extensions of FileInfo
public static class FileInfoExtensions
- Inheritance
-
FileInfoExtensions
- Inherited Members
Methods
LookLikeJsonFrontMatter(IReadOnlyCollection<string>?, ILogger?)
Return true
when the specified collection of lines look like JSON
public static bool LookLikeJsonFrontMatter(this IReadOnlyCollection<string>? lines, ILogger? logger)
Parameters
lines
IReadOnlyCollection<string>collection of lines
logger
ILoggerthe ILogger
Returns
LookLikeMarkdownEntryWithFrontMatter(IReadOnlyCollection<string>?, ILogger?)
Return true
when the specified collection of lines look like Content
public static bool LookLikeMarkdownEntryWithFrontMatter(this IReadOnlyCollection<string>? lines, ILogger? logger)
Parameters
lines
IReadOnlyCollection<string>collection of lines
logger
ILoggerthe ILogger
Returns
LookLikeYamlFrontMatter(IReadOnlyCollection<string>?, ILogger?)
Return true
when the specified collection of lines look like YAML
public static bool LookLikeYamlFrontMatter(this IReadOnlyCollection<string>? lines, ILogger? logger)
Parameters
lines
IReadOnlyCollection<string>collection of lines
logger
ILoggerthe ILogger
Returns
ToFrontMatterLinesAndContentLines(FileInfo?, ILogger?)
Converts the specified FileInfo publications entry into two collections of lines: one for front matter and one for content.
public static (IReadOnlyCollection<string> FrontMatterLines, IReadOnlyCollection<string> ContentLines) ToFrontMatterLinesAndContentLines(this FileInfo? entry, ILogger? logger)
Parameters
Returns
Remarks
This member expects the first line of the entry to be a front matter fence (---
)
or it will return empty collections.
ToIDocumentAndAnyContent(FileInfo?, ILogger?)
public static (IDocument? frontMatter, string? content) ToIDocumentAndAnyContent(this FileInfo? entry, ILogger? logger)
Parameters
Returns
ToJsonObjectAndAnyContent(FileInfo?, ILogger?)
Converts the specified FileInfo into a (JsonObject, string) tuple.
public static (JsonObject? frontMatter, string? content) ToJsonObjectAndAnyContent(this FileInfo? entry, ILogger? logger)
Parameters
Returns
ToJsonString(IReadOnlyCollection<string>?, ILogger?)
Converts the specified collection of lines to a JSON string.
public static string? ToJsonString(this IReadOnlyCollection<string>? lines, ILogger? logger)
Parameters
lines
IReadOnlyCollection<string>collection of lines where LookLikeJsonFrontMatter(IReadOnlyCollection<string>?, ILogger?) returns
true
logger
ILoggerthe ILogger
Returns
ToNewIDocument(FileInfo?, string?, string?, ILogger?)
public static IDocument? ToNewIDocument(this FileInfo? entry, string? title, string? documentPath, ILogger? logger)
Parameters
entry
FileInfothe FileInfo publications entry
title
stringthe Title
documentPath
stringthe Path
logger
ILoggerthe ILogger
Returns
ToYamlString(IReadOnlyCollection<string>?, ILogger?)
Converts the specified collection of lines to a YAML string.
public static string? ToYamlString(this IReadOnlyCollection<string>? lines, ILogger? logger)
Parameters
lines
IReadOnlyCollection<string>collection of lines where LookLikeYamlFrontMatter(IReadOnlyCollection<string>?, ILogger?) returns
true
logger
ILoggerthe ILogger
Returns
WriteNewPublicationEntryWithJsonFrontMatter(FileInfo?, string?, string?, string?, ILogger?)
Writes a new entry with JSON front matter to FullName
public static void WriteNewPublicationEntryWithJsonFrontMatter(this FileInfo? entry, string? title, string? documentPath, string? content, ILogger? logger)
Parameters
entry
FileInfothe FileInfo publications entry
title
stringthe Title
documentPath
stringthe Path
content
stringthe entry content
logger
ILoggerthe ILogger
WriteNewPublicationEntryWithYamlFrontMatter(FileInfo?, string?, string?, string?, ILogger?)
Writes a new entry with YAML front matter to FullName
public static void WriteNewPublicationEntryWithYamlFrontMatter(this FileInfo? entry, string? title, string? documentPath, string? content, ILogger? logger)