public class LineWrappingTextWriter : TextWriter
Public Class LineWrappingTextWriter
Inherits TextWriter
Dim instance As LineWrappingTextWriter
public ref class LineWrappingTextWriter : public TextWriter
If the MaximumLineLength property is not zero, the LineWrappingTextWriter will buffer the data written to it until an explicit new line is present in the text, or until the length of the buffered data exceeds the value of the MaximumLineLength property.
If the length of the buffered data exceeds the value of the MaximumLineLength property, the LineWrappingTextWriter will attempt to find a white-space character to break the line at. If such a white-space character is found, everything before that character is output to the BaseWriter, followed by a line ending, and everything after that character is kept in the buffer. The white-space character itself is not written to the output.
If no suitable place to break the line could be found, the line is broken at the maximum line length. This may occur in the middle of a word. If the Wrapping property is set to EnabledNoForce, lines without a suitable white-space character will not be wrapped and can be longer than the value of the MaximumLineLength property.
After a line break (either one that was caused by wrapping or one that was part of the text), the next line is indented by the number of characters specified by the Indent property, unless the previous line was blank. The length of the indentation counts towards the maximum line length.
When the Flush or FlushAsync method is called, the current contents of the buffer are written to the BaseWriter, followed by a new line, unless the buffer is empty. If the buffer contains only indentation, it is considered empty and no new line is written. Calling Flush has the same effect as writing a new line to the LineWrappingTextWriter if the buffer is not empty. The LineWrappingTextWriter is flushed when the Dispose(Boolean) or DisposeAsync method is called.
The ResetIndent or ResetIndentAsync(CancellationToken) method can be used to move the output position back to the beginning of the line. If the buffer is not empty, is first flushed and indentation is reset to zero on the next line. After the next line break, indentation will again be set to the value of the Indent property.
If there is no maximum line length, output is written directly to the BaseWriter and buffering does not occur. Indentation is still inserted as appropriate.
The Flush, FlushAsync, Dispose(Boolean) and DisposeAsync methods will not write an additional new line if the MaximumLineLength property is zero.
LineWrappingTextWriter | Initializes a new instance of the LineWrappingTextWriter class. |
BaseWriter | Gets the TextWriter that this LineWrappingTextWriter is writing to. |
Encoding |
Gets the character encoding in which the output is written.
(Overrides TextWriterEncoding) |
FormatProvider | Gets an object that controls formatting. (Inherited from TextWriter) |
Indent | Gets or sets the amount of characters to indent all but the first line. |
MaximumLineLength | Gets the maximum length of a line in the output. |
NewLine | Gets or sets the line terminator string used by the current TextWriter. (Overrides TextWriterNewLine) |
Wrapping | Gets or sets a value which indicates how to wrap lines at the maximum line length. |
Close | Closes the current writer and releases any system resources associated with the writer. (Inherited from TextWriter) |
Dispose | Releases all resources used by the TextWriter object. (Inherited from TextWriter) |
Dispose(Boolean) | Releases the unmanaged resources used by the TextWriter and optionally releases the managed resources. (Overrides TextWriterDispose(Boolean)) |
DisposeAsync | Asynchronously releases all resources used by the TextWriter object. (Overrides TextWriterDisposeAsync) |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object) |
Flush | Clears all buffers for the current writer and causes any buffered data to be written to the underlying device. (Overrides TextWriterFlush) |
Flush(Boolean) | Clears all buffers for this TextWriter and causes any buffered data to be written to the underlying writer, optionally inserting an additional new line. |
FlushAsync | Asynchronously clears all buffers for the current writer and causes any buffered data to be written to the underlying device. (Overrides TextWriterFlushAsync) |
FlushAsync(Boolean, CancellationToken) | Clears all buffers for this TextWriter and causes any buffered data to be written to the underlying writer, optionally inserting an additional new line. |
ForConsoleError | Gets a LineWrappingTextWriter that writes to the standard error stream, using ConsoleWindowWidth as the maximum line length. |
ForConsoleOut | Gets a LineWrappingTextWriter that writes to the standard output stream, using ConsoleWindowWidth as the maximum line length. |
ForStringWriter | Gets a LineWrappingTextWriter that writes to a StringWriter. |
GetHashCode | Serves as the default hash function. (Inherited from Object) |
GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject) Obsolete. |
GetType | Gets the Type of the current instance. (Inherited from Object) |
InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject) Obsolete. |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object) |
MemberwiseClone(Boolean) | Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject) |
ResetIndent | Restarts writing on the beginning of the line, without indenting that line. |
ResetIndentAsync | Restarts writing on the beginning of the line, without indenting that line. |
ToString |
Returns a string representation of the current LineWrappingTextWriter
instance.
(Overrides ObjectToString) |
Write(Boolean) | Writes the text representation of a Boolean value to the text stream. (Inherited from TextWriter) |
Write(Char) | Writes a character to the text stream. (Overrides TextWriterWrite(Char)) |
Write(Char) | Writes a character array to the text stream. (Inherited from TextWriter) |
Write(Decimal) | Writes the text representation of a decimal value to the text stream. (Inherited from TextWriter) |
Write(Double) | Writes the text representation of an 8-byte floating-point value to the text stream. (Inherited from TextWriter) |
Write(Int32) | Writes the text representation of a 4-byte signed integer to the text stream. (Inherited from TextWriter) |
Write(Int64) | Writes the text representation of an 8-byte signed integer to the text stream. (Inherited from TextWriter) |
Write(Object) | Writes the text representation of an object to the text stream by calling the ToString method on that object. (Inherited from TextWriter) |
Write(ReadOnlySpanChar) | Writes a character span to the text stream. (Overrides TextWriterWrite(ReadOnlySpanChar)) |
Write(Single) | Writes the text representation of a 4-byte floating-point value to the text stream. (Inherited from TextWriter) |
Write(String) | Writes a string to the text stream. (Overrides TextWriterWrite(String)) |
Write(StringBuilder) | Writes a string builder to the text stream. (Inherited from TextWriter) |
Write(UInt32) | Writes the text representation of a 4-byte unsigned integer to the text stream. (Inherited from TextWriter) |
Write(UInt64) | Writes the text representation of an 8-byte unsigned integer to the text stream. (Inherited from TextWriter) |
Write(String, Object) | Writes a formatted string to the text stream, using the same semantics as the Format(String, Object) method. (Inherited from TextWriter) |
Write(String, Object) | Writes a formatted string to the text stream, using the same semantics as the Format(String, Object) method. (Inherited from TextWriter) |
Write(Char, Int32, Int32) | Writes a subarray of characters to the text stream. (Overrides TextWriterWrite(Char, Int32, Int32)) |
Write(String, Object, Object) | Writes a formatted string to the text stream using the same semantics as the Format(String, Object, Object) method. (Inherited from TextWriter) |
Write(String, Object, Object, Object) | Writes a formatted string to the text stream, using the same semantics as the Format(String, Object, Object, Object) method. (Inherited from TextWriter) |
WriteAsync(Char) | Writes a character to the text stream asynchronously. (Overrides TextWriterWriteAsync(Char)) |
WriteAsync(Char) | Writes a character array to the text stream asynchronously. (Inherited from TextWriter) |
WriteAsync(String) | Writes a string to the text stream asynchronously. (Overrides TextWriterWriteAsync(String)) |
WriteAsync(ReadOnlyMemoryChar, CancellationToken) | Asynchronously writes a character memory region to the text stream. (Overrides TextWriterWriteAsync(ReadOnlyMemoryChar, CancellationToken)) |
WriteAsync(StringBuilder, CancellationToken) | Asynchronously writes a string builder to the text stream. (Inherited from TextWriter) |
WriteAsync(Char, Int32, Int32) | Writes a subarray of characters to the text stream asynchronously. (Overrides TextWriterWriteAsync(Char, Int32, Int32)) |
WriteLine | Writes a line terminator to the text stream. (Inherited from TextWriter) |
WriteLine(Boolean) | Writes the text representation of a Boolean value to the text stream, followed by a line terminator. (Inherited from TextWriter) |
WriteLine(Char) | Writes a character to the text stream, followed by a line terminator. (Inherited from TextWriter) |
WriteLine(Char) | Writes an array of characters to the text stream, followed by a line terminator. (Inherited from TextWriter) |
WriteLine(Decimal) | Writes the text representation of a decimal value to the text stream, followed by a line terminator. (Inherited from TextWriter) |
WriteLine(Double) | Writes the text representation of a 8-byte floating-point value to the text stream, followed by a line terminator. (Inherited from TextWriter) |
WriteLine(Int32) | Writes the text representation of a 4-byte signed integer to the text stream, followed by a line terminator. (Inherited from TextWriter) |
WriteLine(Int64) | Writes the text representation of an 8-byte signed integer to the text stream, followed by a line terminator. (Inherited from TextWriter) |
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. (Inherited from TextWriter) |
WriteLine(ReadOnlySpanChar) | Writes the text representation of a character span to the text stream, followed by a line terminator. (Overrides TextWriterWriteLine(ReadOnlySpanChar)) |
WriteLine(Single) | Writes the text representation of a 4-byte floating-point value to the text stream, followed by a line terminator. (Inherited from TextWriter) |
WriteLine(String) | Writes a string to the text stream, followed by a line terminator. (Inherited from TextWriter) |
WriteLine(StringBuilder) | Writes the text representation of a string builder to the text stream, followed by a line terminator. (Inherited from TextWriter) |
WriteLine(UInt32) | Writes the text representation of a 4-byte unsigned integer to the text stream, followed by a line terminator. (Inherited from TextWriter) |
WriteLine(UInt64) | Writes the text representation of an 8-byte unsigned integer to the text stream, followed by a line terminator. (Inherited from TextWriter) |
WriteLine(String, Object) | Writes a formatted string and a new line to the text stream, using the same semantics as the Format(String, Object) method. (Inherited from TextWriter) |
WriteLine(String, Object) | Writes out a formatted string and a new line to the text stream, using the same semantics as Format(String, Object). (Inherited from TextWriter) |
WriteLine(Char, Int32, Int32) | Writes a subarray of characters to the text stream, followed by a line terminator. (Inherited from TextWriter) |
WriteLine(String, Object, Object) | Writes a formatted string and a new line to the text stream, using the same semantics as the Format(String, Object, Object) method. (Inherited from TextWriter) |
WriteLine(String, Object, Object, Object) | Writes out a formatted string and a new line to the text stream, using the same semantics as Format(String, Object). (Inherited from TextWriter) |
WriteLineAsync | Asynchronously writes a line terminator to the text stream. (Overrides TextWriterWriteLineAsync) |
WriteLineAsync(Char) | Asynchronously writes a character to the text stream, followed by a line terminator. (Overrides TextWriterWriteLineAsync(Char)) |
WriteLineAsync(Char) | Asynchronously writes an array of characters to the text stream, followed by a line terminator. (Inherited from TextWriter) |
WriteLineAsync(String) | Asynchronously writes a string to the text stream, followed by a line terminator. (Overrides TextWriterWriteLineAsync(String)) |
WriteLineAsync(ReadOnlyMemoryChar, CancellationToken) | Asynchronously writes the text representation of a character memory region to the text stream, followed by a line terminator. (Overrides TextWriterWriteLineAsync(ReadOnlyMemoryChar, CancellationToken)) |
WriteLineAsync(StringBuilder, CancellationToken) | Asynchronously writes the text representation of a string builder to the text stream, followed by a line terminator. (Inherited from TextWriter) |
WriteLineAsync(Char, Int32, Int32) | Asynchronously writes a subarray of characters to the text stream, followed by a line terminator. (Overrides TextWriterWriteLineAsync(Char, Int32, Int32)) |
CoreNewLine | Stores the newline characters used for this TextWriter. (Inherited from TextWriter) |