Table of Contents

Class TextOutputGenerator

Namespace
SunamoTextOutputGenerator
Assembly
SunamoTextOutputGenerator.dll

Generates formatted text output with headers, lists, paragraphs, and dictionary formatting.

public class TextOutputGenerator
Inheritance
TextOutputGenerator
Inherited Members
Extension Methods

Properties

Builder

Gets or sets the StringBuilder used for text accumulation.

public StringBuilder Builder { get; set; }

Property Value

StringBuilder

Methods

Append(string)

Appends text without a trailing new line.

public void Append(string text)

Parameters

text string

The text to append.

AppendFormat(string, params string[])

Appends formatted text followed by a new line.

public void AppendFormat(string text, params string[] arguments)

Parameters

text string

The format string.

arguments string[]

The format arguments.

AppendLine()

Appends an empty line.

public void AppendLine()

AppendLine(string)

Appends text followed by a new line.

public void AppendLine(string text)

Parameters

text string

The text to append.

AppendLine(StringBuilder)

Appends the content of a StringBuilder followed by a new line.

public void AppendLine(StringBuilder stringBuilder)

Parameters

stringBuilder StringBuilder

The StringBuilder whose content to append.

AppendLineFormat(string, params string[])

Appends a blank line, then formatted text followed by a new line.

public void AppendLineFormat(string text, params string[] arguments)

Parameters

text string

The format string.

arguments string[]

The format arguments.

CountEvery<T>(IList<KeyValuePair<T, int>>)

Outputs each key-value pair with the count appended.

public void CountEvery<T>(IList<KeyValuePair<T, int>> list)

Parameters

list IList<KeyValuePair<T, int>>

The list of key-value pairs to output.

Type Parameters

T

The type of the key.

Create()

Creates a new instance of TextOutputGenerator.

public static TextOutputGenerator Create()

Returns

TextOutputGenerator

A new TextOutputGenerator instance.

Dictionary(Dictionary<string, List<string>>)

Outputs a dictionary where each entry's values are listed under the key as header.

public void Dictionary(Dictionary<string, List<string>> dictionary)

Parameters

dictionary Dictionary<string, List<string>>

The dictionary to output.

Dictionary(Dictionary<string, int>, string)

Outputs a dictionary of string-int pairs with a delimiter.

public void Dictionary(Dictionary<string, int> dictionary, string delimiter)

Parameters

dictionary Dictionary<string, int>

The dictionary to output.

delimiter string

The delimiter between key and value.

Dictionary(Dictionary<string, string>)

Outputs a string-string dictionary with each entry on one line separated by pipe.

public void Dictionary(Dictionary<string, string> dictionary)

Parameters

dictionary Dictionary<string, string>

The dictionary to output.

DictionaryBothToStringToSingleLine<TKey, TValue>(Dictionary<TKey, TValue>, bool, string)

Outputs a dictionary to single lines with both key and value converted to string.

public string DictionaryBothToStringToSingleLine<TKey, TValue>(Dictionary<TKey, TValue> dictionary, bool isPuttingValueFirst, string delimiter = " ") where TKey : notnull

Parameters

dictionary Dictionary<TKey, TValue>

The dictionary to output.

isPuttingValueFirst bool

Whether to put the value before the key in output.

delimiter string

The delimiter between key and value.

Returns

string

The generated text output.

Type Parameters

TKey

The type of the key.

TValue

The type of the value.

DictionaryKeyValuePair<TKey, TValue>(string, IOrderedEnumerable<KeyValuePair<TKey, TValue>>)

Outputs ordered key-value pairs with a header.

public void DictionaryKeyValuePair<TKey, TValue>(string header, IOrderedEnumerable<KeyValuePair<TKey, TValue>> ordered)

Parameters

header string

The header text.

ordered IOrderedEnumerable<KeyValuePair<TKey, TValue>>

The ordered key-value pairs to output.

Type Parameters

TKey

The type of the key.

TValue

The type of the value.

Dictionary<THeader, TValue>(Dictionary<THeader, List<TValue>>, bool)

Outputs a generic dictionary with optional count-only mode.

public void Dictionary<THeader, TValue>(Dictionary<THeader, List<TValue>> dictionary, bool isOnlyCountInValue = false) where THeader : notnull, IEnumerable<char>

Parameters

dictionary Dictionary<THeader, List<TValue>>

The dictionary to output.

isOnlyCountInValue bool

When true, outputs only key and count instead of full list.

Type Parameters

THeader

The header type (must be IEnumerable of char).

TValue

The type of the list elements.

Dictionary<TKey, TValue>(Dictionary<TKey, TValue>, string)

Outputs a generic dictionary with a configurable delimiter. When delimiter is not pipe, uses header format with each value on separate lines.

public void Dictionary<TKey, TValue>(Dictionary<TKey, TValue> dictionary, string delimiter = "|") where TKey : notnull

Parameters

dictionary Dictionary<TKey, TValue>

The dictionary to output.

delimiter string

The delimiter between key and value.

Type Parameters

TKey

The type of the key.

TValue

The type of the value.

EndRunTime()

Appends a termination message.

public void EndRunTime()

Header(string)

Appends a header surrounded by empty lines.

public void Header(string text)

Parameters

text string

The header text.

IGrouping(IEnumerable<IGrouping<string, string>>)

Outputs grouped strings as a dictionary.

public void IGrouping(IEnumerable<IGrouping<string, string>> grouping)

Parameters

grouping IEnumerable<IGrouping<string, string>>

The grouped strings to output.

List(IList<string>)

Outputs a list of strings, one per line.

public void List(IList<string> list)

Parameters

list IList<string>

The list of strings to output.

List(IList<string>, string)

Outputs a list of strings with a header.

public void List(IList<string> list, string header)

Parameters

list IList<string>

The list of strings to output.

header string

The header text.

ListObject(IList)

Outputs objects as a list by converting each to string.

public void ListObject(IList list)

Parameters

list IList

The list of objects to output.

ListSB(StringBuilder, string)

Outputs a StringBuilder content with a header.

public void ListSB(StringBuilder stringBuilder, string header)

Parameters

stringBuilder StringBuilder

The StringBuilder content to output.

header string

The header text.

ListString(string, string)

Outputs a string value with a header.

public void ListString(string text, string header)

Parameters

text string

The text to output.

header string

The header text.

List<TValue>(IList<TValue>, string, string)

Outputs a list of values with a specified delimiter.

public void List<TValue>(IList<TValue> list, string delimiter = "\r\n", string whenNoEntries = "")

Parameters

list IList<TValue>

The list of values to output.

delimiter string

The delimiter between entries.

whenNoEntries string

Text to display when the list is empty.

Type Parameters

TValue

The type of the list elements.

List<THeader, TValue>(IList<TValue>, THeader)

Outputs a list with a header. Header must implement IEnumerable of char (like string).

public void List<THeader, TValue>(IList<TValue> list, THeader header) where THeader : IEnumerable<char>

Parameters

list IList<TValue>

The list of values to output.

header THeader

The header text.

Type Parameters

THeader

The header type (must be IEnumerable of char).

TValue

The type of the list elements.

List<THeader, TValue>(IList<TValue>, THeader, TextOutputGeneratorArgs)

Outputs a list with a header and formatting options.

public void List<THeader, TValue>(IList<TValue> list, THeader header, TextOutputGeneratorArgs args) where THeader : IEnumerable<char>

Parameters

list IList<TValue>

The list of values to output.

header THeader

The header text.

args TextOutputGeneratorArgs

Formatting arguments controlling output behavior.

Type Parameters

THeader

The header type (must be IEnumerable of char).

TValue

The type of the list elements.

NoData()

Appends a message indicating no data is available.

public void NoData()

PairBullet(string, string)

Outputs a key-value pair as a bullet point line.

public void PairBullet(string key, string value)

Parameters

key string

The key text.

value string

The value text.

Paragraph(string, string)

Outputs a paragraph with a header. Only outputs if text is not empty.

public void Paragraph(string text, string header)

Parameters

text string

The paragraph text.

header string

The header text.

Paragraph(StringBuilder, string)

Outputs a paragraph from a StringBuilder with a header.

public void Paragraph(StringBuilder stringBuilder, string header)

Parameters

stringBuilder StringBuilder

The StringBuilder containing the paragraph text.

header string

The header text.

SingleCharLine(char, int)

Appends a line of repeated characters.

public void SingleCharLine(char paddingChar, int length)

Parameters

paddingChar char

The character to repeat.

length int

The number of times to repeat the character.

StartRunTime(string)

Writes a decorated header with the given text surrounded by repeated characters.

public void StartRunTime(string text)

Parameters

text string

The header text to display.

ToString()

Returns all accumulated text as a string.

public override string ToString()

Returns

string

The generated text output.

Undo()

Undoes the last operation. Not implemented.

public void Undo()