CodeBuilder

public sealed class CodeBuilder
A string builder for composing code-like strings.

Constructors

CodeBuilder

#
Create an empty string builder.
public CodeBuilder()

CodeBuilder

#
Create an empty string builder.
public CodeBuilder(
capacity
The suggested starting size.
)

CodeBuilder

#
Create a string builder.
public CodeBuilder(
content
The initial string.
)

Properties

Depth

#
Gets the indentation depth of the builder.
public int Depth { get; }

DepthText

#
Gets or sets the string to use for indenting.
public string DepthText { get; set; }

Length

#
Gets the current length of the builder.
public int Length { get; }

Prefix

#
Gets the current indentation prefix string.
public string Prefix { get; }

Methods

Add

#
Add a formatted string to the current line.
public void Add(
fragment,
params object[]
arguments
)

Add

#
Add a string to the current line.
public void Add(
fragment
)

AddLine

#
Add a blank line.
public void AddLine()

AddLine

#
Add a formatted line.
public void AddLine(
line,
params object[]
arguments
)

AddLine

#
Add a line of text.
public void AddLine(
line
)

Cs

#
Create a C# constructor statement.
public static string Cs(
Color
colour,
Colour to construct.
accuracy
Decimal places (must be between 0 and 12). If zero, the colour will be constructed from integer channels.
)
C# compatible constructor instruction.

Cs

#
Create a C# constructor statement with adaptive accuracy.
public static string Cs(
Color
colour
Colour to construct.
)
C# compatible constructor instruction.

EnsureNewLine

#
Make sure that the current insertion location is at the start of a new line.
public void EnsureNewLine()

Indent

#
Gets a disposable indentation object.
public IDisposable Indent()

Indent

#
Gets a disposable indentation object.
public IDisposable Indent(
amount
Number of indentations. Should be 1 or higher to make sense.
)

Indent

#
Gets a disposable indentation object.
public IDisposable Indent(
terminus
Terminus string to append after the end of the indentated region.
)

Scope

#
Gets a disposable curly brace scope object.
public IDisposable Scope(
suffix = null
)

ToString

#
Return the code string.
public override string ToString()
Object.ToString