Table of Contents

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 ILogger

the ILogger

Returns

bool

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 ILogger

the ILogger

Returns

bool

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 ILogger

the ILogger

Returns

bool

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

entry FileInfo

the FileInfo publications entry

logger ILogger

the ILogger

Returns

(IReadOnlyCollection<string> FrontMatterLines, IReadOnlyCollection<string> ContentLines)

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?)

Converts the specified FileInfo into a (IDocument, string) tuple.

public static (IDocument? frontMatter, string? content) ToIDocumentAndAnyContent(this FileInfo? entry, ILogger? logger)

Parameters

entry FileInfo

the FileInfo publications entry

logger ILogger

the ILogger

Returns

(IDocument frontMatter, string content)

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

entry FileInfo

the FileInfo publications entry

logger ILogger

the ILogger

Returns

(JsonObject frontMatter, string content)

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 ILogger

the ILogger

Returns

string

ToNewIDocument(FileInfo?, string?, string?, ILogger?)

Converts the specified FileInfo to a new IDocument.

public static IDocument? ToNewIDocument(this FileInfo? entry, string? title, string? documentPath, ILogger? logger)

Parameters

entry FileInfo

the FileInfo publications entry

title string

the Title

documentPath string

the Path

logger ILogger

the ILogger

Returns

IDocument

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 ILogger

the ILogger

Returns

string

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 FileInfo

the FileInfo publications entry

title string

the Title

documentPath string

the Path

content string

the entry content

logger ILogger

the 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)

Parameters

entry FileInfo

the FileInfo publications entry

title string

the Title

documentPath string

the Path

content string

the entry content

logger ILogger

the ILogger