Gutenberg

Class DocumentExtensions

Contains extension methods for Document<T>.

Inheritance
Declaration
public static class DocumentExtensions : Object

Methods

Separated<T>(IEnumerable<Document<T>>, Document<T>)

Returns a Document<T> representing the items in documents concatenated together, with separator in between them.

Declaration
public static Document<T> Separated<T>(this IEnumerable<Document<T>> documents, Document<T> separator)
Parameters
Type Name Description

IEnumerable<Document<T>>

documents

The documents to concatenate

Document<T>

separator

The document to place between each document

Returns
Type Description

Document<T>

A Document<T> representing the items in documents concatenated together, with separator in between them.

Type Parameters
Name Description

T

The type of annotations in the document

Examples
var doc = new Doc[] { "item1", "item2", "item3" }
    .Separated(",");
Console.WriteLine(doc);
// Output:
// item1,item2,item3

SeparatedAndTerminated<T>(IEnumerable<Document<T>>, Document<T>)

Returns a Document<T> representing the items in documents concatenated together, with separator after each one.

Declaration
public static Document<T> SeparatedAndTerminated<T>(this IEnumerable<Document<T>> documents, Document<T> separator)
Parameters
Type Name Description

IEnumerable<Document<T>>

documents

The documents to concatenate

Document<T>

separator

The document to place after each document

Returns
Type Description

Document<T>

A Document<T> representing the items in documents concatenated together, with separator after each one.

Type Parameters
Name Description

T

The type of annotations in the document

Remarks

docs.SeparatedAndTerminated(sep) is equivalent to documents.Separated(separator).Append(separator).

Examples
var doc = new Doc[] { "item1", "item2", "item3" }
    .SeparatedAndTerminated(",");
Console.WriteLine(doc);
// Output:
// item1,item2,item3,