Class IndentedTextWriter
- Namespace
- ValveResourceFormat
- Assembly
- ValveResourceFormat.dll
The same as System.CodeDom.Compiler.IndentedTextWriter but works in partial trust. Taken from System.Data.Entity.Migrations.Utilities.IndentedTextWriter.
public class IndentedTextWriter : TextWriter, IAsyncDisposable, IDisposableInheritance
Implements
Inherited Members
Constructors
IndentedTextWriter()
Initializes a new instance of the ValveResourceFormat.IndentedTextWriter class.
public IndentedTextWriter()IndentedTextWriter(StringWriter)
Initializes a new instance of the ValveResourceFormat.IndentedTextWriter class.
public IndentedTextWriter(StringWriter writer)Parameters
writerStringWriter
Fields
TabString
Specifies the default tab string. This field is constant.
public const string TabString = "\t"Field Value
Properties
Encoding
When overridden in a derived class, returns the character encoding in which the output is written.
public override Encoding Encoding { get; }Property Value
Indent
Gets or sets the number of spaces to indent.
public int Indent { get; set; }Property Value
NewLine
Gets or sets the line terminator string used by the current TextWriter.
[AllowNull]
public override string NewLine { get; set; }Property Value
Methods
Close()
Closes the current writer and releases any system resources associated with the writer.
public override void Close()Dispose(bool)
Releases the unmanaged resources used by the System.IO.TextWriter and optionally releases the managed resources.
protected override void Dispose(bool disposing)Parameters
disposingbool-
true to release both managed and unmanaged resources; false to release only unmanaged resources.
EnsureCapacity(int)
Ensures that the capacity of this writer is at least the specified value.
public int EnsureCapacity(int capacity)Parameters
capacityint-
The new capacity for this writer.
Returns
Flush()
Clears all buffers for the current writer and causes any buffered data to be written to the underlying device.
public override void Flush()Grow(int)
Grows this writer to match the specified min capacity.
public int Grow(int minCapacity)Parameters
minCapacityint-
The minimum capacity for this writer.
Returns
OutputTabs()
Outputs the tab string once for each level of indentation according to the ValveResourceFormat.IndentedTextWriter.Indent property.
protected virtual void OutputTabs()ToString()
Returns a string that represents the current object.
public override string ToString()Returns
- string
-
A string that represents the current object.
Write(string?)
Writes a string to the text stream.
public override void Write(string? value)Parameters
valuestring?-
The string to write.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
Write(bool)
Writes the text representation of a Boolean value to the text stream.
public override void Write(bool value)Parameters
valuebool-
The
Booleanvalue to write.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
Write(char)
Writes a character to the text stream.
public override void Write(char value)Parameters
valuechar-
The character to write to the text stream.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
Write(char[]?)
Writes a character array to the text stream.
public override void Write(char[]? buffer)Parameters
bufferchar[]?-
The character array to write to the text stream.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
Write(char[], int, int)
Writes a subarray of characters to the text stream.
public override void Write(char[] buffer, int index, int count)Parameters
bufferchar[]-
The character array to write data from.
indexint-
The character position in the buffer at which to start retrieving data.
countint-
The number of characters to write.
Exceptions
- ArgumentException
-
The buffer length minus
indexis less thancount. - ArgumentNullException
-
The
bufferparameter is null. - ArgumentOutOfRangeException
-
indexorcountis negative. - ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
Write(decimal)
Writes the text representation of a decimal value to the text stream.
public override void Write(decimal value)Parameters
valuedecimal-
The decimal value to write.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
Write(double)
Writes the text representation of an 8-byte floating-point value to the text stream.
public override void Write(double value)Parameters
valuedouble-
The 8-byte floating-point value to write.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
Write(float)
Writes the text representation of a 4-byte floating-point value to the text stream.
public override void Write(float value)Parameters
valuefloat-
The 4-byte floating-point value to write.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
Write(int)
Writes the text representation of a 4-byte signed integer to the text stream.
public override void Write(int value)Parameters
valueint-
The 4-byte signed integer to write.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
Write(long)
Writes the text representation of an 8-byte signed integer to the text stream.
public override void Write(long value)Parameters
valuelong-
The 8-byte signed integer to write.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
Write(object?) Deprecated
Do not write to string as a generic object, this is probably a mistake.
Writes the text representation of an object to the text stream by calling the ToString method on that object.
[Obsolete("Do not write to string as a generic object, this is probably a mistake.")]
public override void Write(object? value)Parameters
valueobject?-
The object to write.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
Write(string, object?)
Writes a formatted string to the text stream, using the same semantics as the System.String.Format(System.String,System.Object) method.
public override void Write(string format, object? arg0)Parameters
Exceptions
- ArgumentNullException
-
formatis null. - ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
- FormatException
-
<code class="paramref">format</code> is not a valid composite format string.-or-
The index of a format item is less than 0 (zero), or greater than or equal to the number of objects to be formatted (which, for this method overload, is one).
Write(string, object?, object?)
Writes a formatted string to the text stream using the same semantics as the System.String.Format(System.String,System.Object,System.Object) method.
public override void Write(string format, object? arg0, object? arg1)Parameters
formatstring-
A composite format string.
arg0object?-
The first object to format and write.
arg1object?-
The second object to format and write.
Exceptions
- ArgumentNullException
-
formatis null. - ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
- FormatException
-
<code class="paramref">format</code> is not a valid composite format string.-or-
The index of a format item is less than 0 (zero) or greater than or equal to the number of objects to be formatted (which, for this method overload, is two).
Write(string, params object?[])
Writes a formatted string to the text stream, using the same semantics as the System.String.Format(System.String,System.Object[]) method.
public override void Write(string format, params object?[] arg)Parameters
formatstring-
A composite format string.
argobject?[]-
An object array that contains zero or more objects to format and write.
Exceptions
- ArgumentNullException
-
formatorargis null. - ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
- FormatException
-
<code class="paramref">format</code> is not a valid composite format string.-or-
The index of a format item is less than 0 (zero), or greater than or equal to the length of the
argarray.
WriteLine(string?)
Writes a string to the text stream, followed by a line terminator.
public override void WriteLine(string? value)Parameters
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
WriteLine(ReadOnlySpan<char>)
Writes the text representation of a character span to the text stream, followed by a line terminator.
public override void WriteLine(ReadOnlySpan<char> buffer)Parameters
bufferReadOnlySpan<char>-
The char span value to write to the text stream.
WriteLine()
Writes a line terminator to the text stream.
public override void WriteLine()Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
WriteLine(bool)
Writes the text representation of a Boolean value to the text stream, followed by a line terminator.
public override void WriteLine(bool value)Parameters
valuebool-
The
Booleanvalue to write.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
WriteLine(char)
Writes a character to the text stream, followed by a line terminator.
public override void WriteLine(char value)Parameters
valuechar-
The character to write to the text stream.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
WriteLine(char[]?)
Writes an array of characters to the text stream, followed by a line terminator.
public override void WriteLine(char[]? buffer)Parameters
bufferchar[]?-
The character array from which data is read.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
WriteLine(char[], int, int)
Writes a subarray of characters to the text stream, followed by a line terminator.
public override void WriteLine(char[] buffer, int index, int count)Parameters
bufferchar[]-
The character array from which data is read.
indexint-
The character position in
bufferat which to start reading data. countint-
The maximum number of characters to write.
Exceptions
- ArgumentException
-
The buffer length minus
indexis less thancount. - ArgumentNullException
-
The
bufferparameter is null. - ArgumentOutOfRangeException
-
indexorcountis negative. - ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
WriteLine(double)
Writes the text representation of a 8-byte floating-point value to the text stream, followed by a line terminator.
public override void WriteLine(double value)Parameters
valuedouble-
The 8-byte floating-point value to write.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
WriteLine(float)
Writes the text representation of a 4-byte floating-point value to the text stream, followed by a line terminator.
public override void WriteLine(float value)Parameters
valuefloat-
The 4-byte floating-point value to write.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
WriteLine(int)
Writes the text representation of a 4-byte signed integer to the text stream, followed by a line terminator.
public override void WriteLine(int value)Parameters
valueint-
The 4-byte signed integer to write.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
WriteLine(long)
Writes the text representation of an 8-byte signed integer to the text stream, followed by a line terminator.
public override void WriteLine(long value)Parameters
valuelong-
The 8-byte signed integer to write.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
WriteLine(object?)
Writes the text representation of an object to the text stream, by calling the ToString method on that object, followed by a line terminator.
public override void WriteLine(object? value)Parameters
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
WriteLine(uint)
Writes the text representation of a 4-byte unsigned integer to the text stream, followed by a line terminator.
public override void WriteLine(uint value)Parameters
valueuint-
The 4-byte unsigned integer to write.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
WriteLine(ulong)
Writes the text representation of an 8-byte unsigned integer to the text stream, followed by a line terminator.
public override void WriteLine(ulong value)Parameters
valueulong-
The 8-byte unsigned integer to write.
Exceptions
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
WriteLine(string, object?)
Writes a formatted string and a new line to the text stream, using the same semantics as the System.String.Format(System.String,System.Object) method.
public override void WriteLine(string format, object? arg0)Parameters
Exceptions
- ArgumentNullException
-
formatis null. - ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
- FormatException
-
<code class="paramref">format</code> is not a valid composite format string.-or-
The index of a format item is less than 0 (zero), or greater than or equal to the number of objects to be formatted (which, for this method overload, is one).
WriteLine(string, object?, object?)
Writes a formatted string and a new line to the text stream, using the same semantics as the System.String.Format(System.String,System.Object,System.Object) method.
public override void WriteLine(string format, object? arg0, object? arg1)Parameters
formatstring-
A composite format string.
arg0object?-
The first object to format and write.
arg1object?-
The second object to format and write.
Exceptions
- ArgumentNullException
-
formatis null. - ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
- FormatException
-
<code class="paramref">format</code> is not a valid composite format string.-or-
The index of a format item is less than 0 (zero), or greater than or equal to the number of objects to be formatted (which, for this method overload, is two).
WriteLine(string, object?, object?, object?)
Writes out a formatted string and a new line to the text stream, using the same semantics as System.String.Format(System.String,System.Object).
public override void WriteLine(string format, object? arg0, object? arg1, object? arg2)Parameters
formatstring-
A composite format string.
arg0object?-
The first object to format and write.
arg1object?-
The second object to format and write.
arg2object?-
The third object to format and write.
Exceptions
- ArgumentNullException
-
formatis null. - ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
- FormatException
-
<code class="paramref">format</code> is not a valid composite format string.-or-
The index of a format item is less than 0 (zero), or greater than or equal to the number of objects to be formatted (which, for this method overload, is three).
WriteLine(string, params object?[])
Writes out a formatted string and a new line to the text stream, using the same semantics as System.String.Format(System.String,System.Object).
public override void WriteLine(string format, params object?[] arg)Parameters
formatstring-
A composite format string.
argobject?[]-
An object array that contains zero or more objects to format and write.
Exceptions
- ArgumentNullException
-
A string or object is passed in as null.
- ObjectDisposedException
-
The System.IO.TextWriter is closed.
- IOException
-
An I/O error occurs.
- FormatException
-
<code class="paramref">format</code> is not a valid composite format string.-or-
The index of a format item is less than 0 (zero), or greater than or equal to the length of the
argarray.
WriteLine(string, params ReadOnlySpan<object?>)
Writes out a formatted string and a new line to the text stream, using the same semantics as System.String.Format(System.String,System.ReadOnlySpan{System.Object}).
public override void WriteLine(string format, params ReadOnlySpan<object?> arg)Parameters
formatstring-
A composite format string.
argReadOnlySpan<object?>-
An object span that contains zero or more objects to format and write.