Class IndentedStringBuilder
- Namespace
- Microsoft.EntityFrameworkCore.Infrastructure
- Assembly
- Microsoft.EntityFrameworkCore.dll
A thin wrapper over StringBuilder that adds indentation to each line built.
This type is typically used by database providers (and other extensions). It is generally not used in application code.
public class IndentedStringBuilder
- Inheritance
-
IndentedStringBuilder
- Inherited Members
Remarks
See Implementation of database providers and extensions for more information and examples.
Constructors
IndentedStringBuilder()
public IndentedStringBuilder()
Properties
IndentCount
Gets the current indent level.
public virtual int IndentCount { get; }
Property Value
- int
The current indent level.
Length
The current length of the built string.
public virtual int Length { get; }
Property Value
Methods
Append(char)
Appends the current indent and then the given char to the string being built.
public virtual IndentedStringBuilder Append(char value)
Parameters
value
charThe char to append.
Returns
- IndentedStringBuilder
This builder so that additional calls can be chained.
Append(IEnumerable<char>)
Appends the current indent and then the given chars to the string being built.
public virtual IndentedStringBuilder Append(IEnumerable<char> value)
Parameters
value
IEnumerable<char>The chars to append.
Returns
- IndentedStringBuilder
This builder so that additional calls can be chained.
Append(IEnumerable<string>)
Appends the current indent and then the given strings to the string being built.
public virtual IndentedStringBuilder Append(IEnumerable<string> value)
Parameters
value
IEnumerable<string>The strings to append.
Returns
- IndentedStringBuilder
This builder so that additional calls can be chained.
Append(FormattableString)
Appends the current indent and then the given string to the string being built.
public virtual IndentedStringBuilder Append(FormattableString value)
Parameters
value
FormattableStringThe string to append.
Returns
- IndentedStringBuilder
This builder so that additional calls can be chained.
Append(string)
Appends the current indent and then the given string to the string being built.
public virtual IndentedStringBuilder Append(string value)
Parameters
value
stringThe string to append.
Returns
- IndentedStringBuilder
This builder so that additional calls can be chained.
AppendJoin(IEnumerable<string>, string)
Concatenates the members of the given collection, using the specified separator between each member, and then appends the resulting string,
public virtual IndentedStringBuilder AppendJoin(IEnumerable<string> values, string separator = ", ")
Parameters
values
IEnumerable<string>The values to concatenate.
separator
stringThe separator.
Returns
- IndentedStringBuilder
This builder so that additional calls can be chained.
AppendJoin(string, params string[])
Concatenates the members of the given collection, using the specified separator between each member, and then appends the resulting string,
public virtual IndentedStringBuilder AppendJoin(string separator, params string[] values)
Parameters
Returns
- IndentedStringBuilder
This builder so that additional calls can be chained.
AppendLine()
Appends a new line to the string being built.
public virtual IndentedStringBuilder AppendLine()
Returns
- IndentedStringBuilder
This builder so that additional calls can be chained.
AppendLine(FormattableString)
Appends the current indent, the given string, and a new line to the string being built.
public virtual IndentedStringBuilder AppendLine(FormattableString value)
Parameters
value
FormattableStringThe string to append.
Returns
- IndentedStringBuilder
This builder so that additional calls can be chained.
AppendLine(string)
Appends the current indent, the given string, and a new line to the string being built.
public virtual IndentedStringBuilder AppendLine(string value)
Parameters
value
stringThe string to append.
Returns
- IndentedStringBuilder
This builder so that additional calls can be chained.
Remarks
If the given string itself contains a new line, the part of the string after that new line will not be indented.
AppendLines(string, bool)
Separates the given string into lines, and then appends each line, prefixed by the current indent and followed by a new line, to the string being built.
public virtual IndentedStringBuilder AppendLines(string value, bool skipFinalNewline = false)
Parameters
value
stringThe string to append.
skipFinalNewline
boolIf true, then the terminating new line is not added after the last line.
Returns
- IndentedStringBuilder
This builder so that additional calls can be chained.
Clear()
Resets this builder ready to build a new string.
public virtual IndentedStringBuilder Clear()
Returns
- IndentedStringBuilder
This builder so that additional calls can be chained.
DecrementIndent()
Decrements the indent.
public virtual IndentedStringBuilder DecrementIndent()
Returns
- IndentedStringBuilder
This builder so that additional calls can be chained.
IncrementIndent()
Increments the indent.
public virtual IndentedStringBuilder IncrementIndent()
Returns
- IndentedStringBuilder
This builder so that additional calls can be chained.
Indent()
Creates a scoped indenter that will increment the indent, then decrement it when disposed.
public virtual IDisposable Indent()
Returns
- IDisposable
An indenter.
SuspendIndent()
Temporarily disables all indentation. Restores the original indentation when the returned object is disposed.
public virtual IDisposable SuspendIndent()
Returns
- IDisposable
An object that restores the original indentation when disposed.
ToString()
Returns the built string.
public override string ToString()
Returns
- string
The built string.