CodeBuilder

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

Constructors

CodeBuilder

#
public CodeBuilder()
Create an empty string builder.

CodeBuilder

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

CodeBuilder

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

Properties

Depth

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

DepthText

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

Length

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

Prefix

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

Methods

Add

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

Add

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

AddLine

#
public void AddLine()
Add a blank line.

AddLine

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

AddLine

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

Cs

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

Cs

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

EnsureNewLine

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

Indent

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

Indent

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

Indent

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

Scope

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

ToString

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