Table of Contents

Class TextBuilder

Namespace
SunamoTextOutputGenerator
Assembly
SunamoTextOutputGenerator.dll

Text builder that supports both StringBuilder and List modes with undo capability.

public class TextBuilder : ITextBuilder
Inheritance
TextBuilder
Implements
Inherited Members
Extension Methods

Constructors

TextBuilder(bool)

Initializes a new instance of the TextBuilder class.

public TextBuilder(bool isUsingList = false)

Parameters

isUsingList bool

When true, uses a list of strings instead of StringBuilder. Setting this to true requires justification because it changes the internal storage mode.

Properties

Builder

Gets or sets the internal StringBuilder used when not in list mode.

public StringBuilder Builder { get; set; }

Property Value

StringBuilder

CanUndo

Gets or sets a value indicating whether undo operation is enabled.

public bool CanUndo { get; set; }

Property Value

bool

List

Gets or sets the list of lines used in list mode (e.g. for PowershellRunner).

public List<string>? List { get; set; }

Property Value

List<string>

PrependEveryNoWhite

Gets or sets text to prepend before every non-whitespace append.

public string PrependEveryNoWhite { get; set; }

Property Value

string

Methods

Append(object)

Appends the string representation of an object.

public void Append(object value)

Parameters

value object

The object to append.

Append(string)

Appends text.

public void Append(string text)

Parameters

text string

The text to append.

AppendLine()

Appends a new 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.

Clear()

Clears all content.

public void Clear()

Create(bool)

Creates a new ITextBuilder instance.

public static ITextBuilder Create(bool isUsingList = false)

Parameters

isUsingList bool

Whether to use list mode.

Returns

ITextBuilder

A new ITextBuilder instance.

ToString()

Returns the built text. If using list mode, joins lines with newlines.

public override string ToString()

Returns

string

The built text as a string.

Undo()

Undoes the last append operation.

public void Undo()