Class MessageTextWriter
Implements a text writer which writes to multiple different text writers at once.
public class MessageTextWriter : TextWriter, IAsyncDisposable, IDisposable
- Inheritance
-
MessageTextWriter
- Implements
- Inherited Members
- Extension Methods
Remarks
Only overrides members internally used by MessageWriter.
Constructors
MessageTextWriter(TextWriter[])
public MessageTextWriter(TextWriter[] writers)
Parameters
writersTextWriter[]
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
- Encoding
The character encoding in which the output is written.
Writers
public TextWriter[] Writers { get; }
Property Value
Methods
AddWriter(TextWriter)
public void AddWriter(TextWriter writer)
Parameters
writerTextWriter
AddWriters(TextWriter[])
public void AddWriters(TextWriter[] writers)
Parameters
writersTextWriter[]
Dispose()
public void Dispose()
Dispose(bool)
Releases the unmanaged resources used by the TextWriter and optionally releases the managed resources.
protected override void Dispose(bool disposing)
Parameters
disposingbooltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
Flush()
Clears all buffers for the current writer and causes any buffered data to be written to the underlying device.
public override void Flush()
FlushAsync()
Asynchronously clears all buffers for the current writer and causes any buffered data to be written to the underlying device.
public override Task FlushAsync()
Returns
- Task
A task that represents the asynchronous flush operation.
Exceptions
- ObjectDisposedException
The text writer is disposed.
- InvalidOperationException
The writer is currently in use by a previous write operation.
FlushAsync(CancellationToken)
Asynchronously clears all buffers for the current writer and causes any buffered data to be written to the underlying device.
public override Task FlushAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe CancellationToken to monitor for cancellation requests.
Returns
Exceptions
- ObjectDisposedException
The text writer is disposed.
- InvalidOperationException
The writer is currently in use by a previous write operation.
- OperationCanceledException
The cancellation token was canceled. This exception is stored into the returned task.
RemoveWriter(TextWriter)
public void RemoveWriter(TextWriter writer)
Parameters
writerTextWriter
Restore()
public void Restore()
SetWriters(TextWriter[])
public void SetWriters(TextWriter[] writers)
Parameters
writersTextWriter[]
Store()
public void Store()
Write(string)
Writes a string to the text stream.
public override void Write(string value)
Parameters
valuestringThe string to write.
Exceptions
- ObjectDisposedException
The TextWriter is closed.
- IOException
An I/O error occurs.
WriteLine()
Writes a line terminator to the text stream.
public override void WriteLine()
Exceptions
- ObjectDisposedException
The TextWriter is closed.
- IOException
An I/O error occurs.
WriteLine(string)
Writes a string to the text stream, followed by a line terminator.
public override void WriteLine(string value)
Parameters
Exceptions
- ObjectDisposedException
The TextWriter is closed.
- IOException
An I/O error occurs.