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
isUsingListboolWhen 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
CanUndo
Gets or sets a value indicating whether undo operation is enabled.
public bool CanUndo { get; set; }
Property Value
List
Gets or sets the list of lines used in list mode (e.g. for PowershellRunner).
public List<string>? List { get; set; }
Property Value
PrependEveryNoWhite
Gets or sets text to prepend before every non-whitespace append.
public string PrependEveryNoWhite { get; set; }
Property Value
Methods
Append(object)
Appends the string representation of an object.
public void Append(object value)
Parameters
valueobjectThe object to append.
Append(string)
Appends text.
public void Append(string text)
Parameters
textstringThe 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
textstringThe 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
isUsingListboolWhether 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()