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
Methods
Append(string)
Appends text without a trailing new line.
public void Append(string text)
Parameters
textstringThe text to append.
AppendFormat(string, params string[])
Appends formatted text followed by a new line.
public void AppendFormat(string text, params string[] arguments)
Parameters
AppendLine()
Appends an empty line.
public void AppendLine()
AppendLine(string)
Appends text followed by a new line.
public void AppendLine(string text)
Parameters
textstringThe text to append.
AppendLine(StringBuilder)
Appends the content of a StringBuilder followed by a new line.
public void AppendLine(StringBuilder stringBuilder)
Parameters
stringBuilderStringBuilderThe 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
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
listIList<KeyValuePair<T, int>>The list of key-value pairs to output.
Type Parameters
TThe 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
dictionaryDictionary<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
dictionaryDictionary<string, int>The dictionary to output.
delimiterstringThe 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
dictionaryDictionary<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
dictionaryDictionary<TKey, TValue>The dictionary to output.
isPuttingValueFirstboolWhether to put the value before the key in output.
delimiterstringThe delimiter between key and value.
Returns
- string
The generated text output.
Type Parameters
TKeyThe type of the key.
TValueThe 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
headerstringThe header text.
orderedIOrderedEnumerable<KeyValuePair<TKey, TValue>>The ordered key-value pairs to output.
Type Parameters
TKeyThe type of the key.
TValueThe 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
dictionaryDictionary<THeader, List<TValue>>The dictionary to output.
isOnlyCountInValueboolWhen true, outputs only key and count instead of full list.
Type Parameters
THeaderThe header type (must be IEnumerable of char).
TValueThe 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
dictionaryDictionary<TKey, TValue>The dictionary to output.
delimiterstringThe delimiter between key and value.
Type Parameters
TKeyThe type of the key.
TValueThe 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
textstringThe header text.
IGrouping(IEnumerable<IGrouping<string, string>>)
Outputs grouped strings as a dictionary.
public void IGrouping(IEnumerable<IGrouping<string, string>> grouping)
Parameters
groupingIEnumerable<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>, string)
Outputs a list of strings with a header.
public void List(IList<string> list, string header)
Parameters
ListObject(IList)
Outputs objects as a list by converting each to string.
public void ListObject(IList list)
Parameters
listIListThe list of objects to output.
ListSB(StringBuilder, string)
Outputs a StringBuilder content with a header.
public void ListSB(StringBuilder stringBuilder, string header)
Parameters
stringBuilderStringBuilderThe StringBuilder content to output.
headerstringThe header text.
ListString(string, string)
Outputs a string value with a header.
public void ListString(string text, string header)
Parameters
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
listIList<TValue>The list of values to output.
delimiterstringThe delimiter between entries.
whenNoEntriesstringText to display when the list is empty.
Type Parameters
TValueThe 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
listIList<TValue>The list of values to output.
headerTHeaderThe header text.
Type Parameters
THeaderThe header type (must be IEnumerable of char).
TValueThe 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
listIList<TValue>The list of values to output.
headerTHeaderThe header text.
argsTextOutputGeneratorArgsFormatting arguments controlling output behavior.
Type Parameters
THeaderThe header type (must be IEnumerable of char).
TValueThe 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
Paragraph(string, string)
Outputs a paragraph with a header. Only outputs if text is not empty.
public void Paragraph(string text, string header)
Parameters
Paragraph(StringBuilder, string)
Outputs a paragraph from a StringBuilder with a header.
public void Paragraph(StringBuilder stringBuilder, string header)
Parameters
stringBuilderStringBuilderThe StringBuilder containing the paragraph text.
headerstringThe header text.
SingleCharLine(char, int)
Appends a line of repeated characters.
public void SingleCharLine(char paddingChar, int length)
Parameters
StartRunTime(string)
Writes a decorated header with the given text surrounded by repeated characters.
public void StartRunTime(string text)
Parameters
textstringThe 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()