Click or drag to resize

LineWrappingTextWriter Constructor

Initializes a new instance of the LineWrappingTextWriter class.

Namespace:  Ookii.CommandLine
Assembly:  Ookii.CommandLine (in Ookii.CommandLine.dll) Version: 2.3.0
Syntax
public LineWrappingTextWriter(
	TextWriter baseWriter,
	int maximumLineLength,
	bool disposeBaseWriter
)

Parameters

baseWriter
Type: System.IOTextWriter
The TextWriter to which to write the wrapped output.
maximumLineLength
Type: SystemInt32
The maximum length of a line, in characters; a value of less than 1 or larger than 65536 means there is no maximum line length.
disposeBaseWriter
Type: SystemBoolean
If set to the baseWriter will be disposed when the LineWrappingTextWriter is disposed.
Exceptions
ExceptionCondition
ArgumentNullExceptionbaseWriter is .
Remarks

The largest maximumLineLength value supported is 65535. Above that, line length is considered to be unbounded. This is done to avoid having to allocate very large buffers to support these long line lengths.

If you want to write to the console, use Out or Error as the baseWriter and specify WindowWidth - 1 as the maximumLineLength and for disposeBaseWriter. If you don't subtract one from the window width, additional empty lines can be printed if a line is exactly the width of the console. You can easily create a LineWrappingTextWriter that writes to the console by using the ForConsoleOut and ForConsoleError methods.

When the console output is redirected to a file, Microsoft .Net will still report the console's actual window width, but on Mono the value of WindowWidth will be 0. In that case, the LineWrappingTextWriter will use no line limit.

See Also