Class MultiTextWriter
- Namespace
- Existential
- Assembly
- Existential.Net.dll
An implementation of System.IO.TextWriter that's constructed with a collection of IWriteStrategy. When its write methods are invoked, they will write the provided text using each of the strategies in the collection, allowing the same text to be directed to multiple outputs.
public class MultiTextWriter : TextWriter, IDisposable
- Inheritance
-
System.ObjectSystem.MarshalByRefObjectSystem.IO.TextWriterMultiTextWriter
- Implements
-
System.IDisposable
- Inherited Members
-
System.IO.TextWriter.CoreNewLineSystem.IO.TextWriter.NullSystem.IO.TextWriter.Close()System.IO.TextWriter.Dispose()System.IO.TextWriter.Dispose(System.Boolean)System.IO.TextWriter.Flush()System.IO.TextWriter.FlushAsync()System.IO.TextWriter.Synchronized(System.IO.TextWriter)System.IO.TextWriter.WriteAsync(System.Char[])System.IO.TextWriter.WriteLineAsync(System.Char[])System.IO.TextWriter.WriteLineAsync(System.String)System.IO.TextWriter.FormatProviderSystem.IO.TextWriter.NewLineSystem.MarshalByRefObject.GetLifetimeService()System.MarshalByRefObject.InitializeLifetimeService()System.MarshalByRefObject.MemberwiseClone(System.Boolean)System.Object.Equals(System.Object, System.Object)System.Object.GetType()System.Object.MemberwiseClone()System.Object.ReferenceEquals(System.Object, System.Object)System.Object.ToString()
- Extension Methods
Remarks
This class is a custom implementation of the TextWriter abstract class. It overrides the base class methods to provide functionality for writing using multiple IWriteStrategy instances.
Constructors
MultiTextWriter(IReadOnlyCollection<IWriteStrategy>)
Initialises a new instance of the MultiTextWriter class.
public MultiTextWriter(IReadOnlyCollection<IWriteStrategy> inWriteStrategies)
Parameters
inWriteStrategiesSystem.Collections.Generic.IReadOnlyCollection<IWriteStrategy>A collection of write strategies.
MultiTextWriter(IReadOnlyCollection<IWriteStrategy>, IFormatProvider)
Initialises a new instance of the MultiTextWriter class with the specified format provider.
public MultiTextWriter(IReadOnlyCollection<IWriteStrategy> inWriteStrategies, IFormatProvider inFormatProvider)
Parameters
inWriteStrategiesSystem.Collections.Generic.IReadOnlyCollection<IWriteStrategy>A collection of write strategies.
inFormatProviderSystem.IFormatProviderAn System.IFormatProvider object that controls formatting.
Properties
Encoding
Gets the default encoding for this .NET implementation, which will be used for the Trace output.
public override Encoding Encoding { get; }
Property Value
- System.Text.Encoding
Methods
Equals(Object)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object obj)
Parameters
objSystem.ObjectThe object to compare with the current instance.
Returns
- System.Boolean
true if
objand this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Gets a hash code for the MultiTextWriter instance.
public override int GetHashCode()
Returns
- System.Int32
A hash code for the MultiTextWriter instance.
Write(Boolean)
Writes the text representation of a Boolean value to the trace listeners in the System.Diagnostics.Trace.Listeners collection.
public override void Write(bool value)
Parameters
valueSystem.BooleanA Boolean value to write to the System.Diagnostics.Trace.Listeners collection.
Write(Char)
Writes a character to the trace listeners in the System.Diagnostics.Trace.Listeners collection.
public override void Write(char value)
Parameters
valueSystem.CharA character to write to the System.Diagnostics.Trace.Listeners collection.
Write(Char[])
Writes an array of characters to the trace listeners in the System.Diagnostics.Trace.Listeners collection.
public override void Write(char[] buffer)
Parameters
bufferSystem.Char[]An array of characters to write to the System.Diagnostics.Trace.Listeners collection.
Write(Char[], Int32, Int32)
Writes a subarray of characters to the trace listeners in the System.Diagnostics.Trace.Listeners collection.
public override void Write(char[] buffer, int index, int count)
Parameters
bufferSystem.Char[]An array of characters.
indexSystem.Int32The starting position within
bufferof the characters to write to the trace listeners in the System.Diagnostics.Trace.Listeners collection.countSystem.Int32The number of characters within
bufferto use.
Exceptions
- System.ArgumentNullException
bufferis null.- System.ArgumentOutOfRangeException
indexorcountis less than zero.-or-
The sum of
indexandcountis greater than the number of elements inbuffer.
Write(Decimal)
Writes the value of the decimal's ToString() method to the trace listeners in the System.Diagnostics.Trace.Listeners collection.
public override void Write(decimal value)
Parameters
valueSystem.DecimalA decimal value to write to the System.Diagnostics.Trace.Listeners collection.
Write(Double)
Writes the value of the double's ToString() method to the trace listeners in the System.Diagnostics.Trace.Listeners collection.
public override void Write(double value)
Parameters
valueSystem.DoubleA double value to write to the System.Diagnostics.Trace.Listeners collection.
Write(Int32)
Writes the value of the Int32's ToString() method to the trace listeners in the System.Diagnostics.Trace.Listeners collection.
public override void Write(int value)
Parameters
valueSystem.Int32An Int32 value to write to the System.Diagnostics.Trace.Listeners collection.
Write(Int64)
Writes the value of the Int64's ToString() method to the trace listeners in the System.Diagnostics.Trace.Listeners collection.
public override void Write(long value)
Parameters
valueSystem.Int64An Int64 value to write to the System.Diagnostics.Trace.Listeners collection.
Write(Object)
Writes the value of the object's ToString() method to the trace listeners in the System.Diagnostics.Trace.Listeners collection.
public override void Write(object value)
Parameters
valueSystem.ObjectAn object value to write to the System.Diagnostics.Trace.Listeners collection.
Write(Single)
Writes the value of the float's ToString() method to the trace listeners in the System.Diagnostics.Trace.Listeners collection.
public override void Write(float value)
Parameters
valueSystem.SingleA float value to write to the System.Diagnostics.Trace.Listeners collection.
Write(String)
Writes a message to the trace listeners in the System.Diagnostics.Trace.Listeners collection.
public override void Write(string value)
Parameters
valueSystem.StringA message to write to the System.Diagnostics.Trace.Listeners collection.
Write(String, Object)
Writes a formatted string to the trace listeners in the System.Diagnostics.Trace.Listeners collection, using the same semantics as the System.String.Format(System.IFormatProvider,System.String,System.Object) method.
public override void Write(string format, object arg0)
Parameters
formatSystem.StringA composite format string.
arg0System.ObjectThe object to format.
Exceptions
- System.ArgumentNullException
formatis null orarg0is null.- System.FormatException
formatis invalid.-or-
The index of a
formatitem is not zero.
Write(String, Object, Object)
Writes a formatted string to the trace listeners in the System.Diagnostics.Trace.Listeners collection, using the same semantics as the System.String.Format(System.IFormatProvider,System.String,System.Object,System.Object) method.
public override void Write(string format, object arg0, object arg1)
Parameters
formatSystem.StringA composite format string.
arg0System.ObjectThe first object to format.
arg1System.ObjectThe second object to format.
Exceptions
- System.ArgumentNullException
formatis null orarg0is null orarg1is null.- System.FormatException
formatis invalid.-or-
The index of a
formatitem is less than zero, or greater than or equal to two.
Write(String, Object, Object, Object)
Writes a formatted string to the trace listeners in the System.Diagnostics.Trace.Listeners collection, using the same semantics as the System.String.Format(System.IFormatProvider,System.String,System.Object,System.Object,System.Object) method.
public override void Write(string format, object arg0, object arg1, object arg2)
Parameters
formatSystem.StringA composite format string.
arg0System.ObjectThe first object to format.
arg1System.ObjectThe second object to format.
arg2System.ObjectThe third object to format.
Exceptions
- System.ArgumentNullException
formatis null orarg0is null orarg1is null orarg2is null.- System.FormatException
formatis invalid.-or-
The index of a
formatitem is less than zero, or greater than or equal to three.
Write(String, Object[])
Writes a formatted string to the trace listeners in the System.Diagnostics.Trace.Listeners collection, using the same semantics as the System.String.Format(System.IFormatProvider,System.String,System.Object[]) method.
public override void Write(string format, params object[] arg)
Parameters
formatSystem.StringA composite format string.
argSystem.Object[]An object array that contains zero or more objects to format.
Exceptions
- System.ArgumentNullException
formatorargis null.- System.FormatException
formatis invalid.-or-
The index of a
formatitem is less than zero, or greater than or equal to the length of theargarray.
Write(UInt32)
Writes the value of the UInt32's ToString() method to the trace listeners in the System.Diagnostics.Trace.Listeners collection.
[CLSCompliant(false)]
public override void Write(uint value)
Parameters
valueSystem.UInt32A UInt32 value to write to the System.Diagnostics.Trace.Listeners collection.
Write(UInt64)
Writes the value of the UInt64's ToString() method to the trace listeners in the System.Diagnostics.Trace.Listeners collection.
[CLSCompliant(false)]
public override void Write(ulong value)
Parameters
valueSystem.UInt64A UInt64 value to write to the System.Diagnostics.Trace.Listeners collection.
WriteAsync(Char)
Writes a character to the trace listeners in the System.Diagnostics.Trace.Listeners collection asynchronously.
public override Task WriteAsync(char value)
Parameters
valueSystem.CharA character to write to the System.Diagnostics.Trace.Listeners collection.
Returns
- System.Threading.Tasks.Task
A Task that represents the asynchronous write operation.
WriteAsync(Char[], Int32, Int32)
Writes a subarray of characters to the trace listeners in the System.Diagnostics.Trace.Listeners collection asynchronously.
public override Task WriteAsync(char[] buffer, int index, int count)
Parameters
bufferSystem.Char[]An array of characters.
indexSystem.Int32The starting position within
bufferof the characters to write to the System.Diagnostics.Trace.Listeners.countSystem.Int32The number of characters within
bufferto use.
Returns
- System.Threading.Tasks.Task
A Task that represents the asynchronous write operation.
Exceptions
- System.ArgumentNullException
bufferis null.- System.ArgumentOutOfRangeException
indexorcountis less than zero.-or-
The sum of
indexandcountis greater than the number of elements inbuffer.
WriteAsync(String)
Writes a string to the trace listeners in the System.Diagnostics.Trace.Listeners collection asynchronously.
public override Task WriteAsync(string value)
Parameters
valueSystem.StringThe message to be written to the System.Diagnostics.Trace.Listeners.
Returns
- System.Threading.Tasks.Task
A Task that represents the asynchronous write operation.
WriteLine()
Writes a line terminator to the trace listeners in the System.Diagnostics.Trace.Listeners collection.
public override void WriteLine()
WriteLine(Boolean)
Writes the text representation of a Boolean value to the trace listeners in the System.Diagnostics.Trace.Listeners collection, followed by a line terminator.
public override void WriteLine(bool value)
Parameters
valueSystem.BooleanA Boolean value to write to the System.Diagnostics.Trace.Listeners collection.
WriteLine(Char)
Writes a character to the trace listeners in the System.Diagnostics.Trace.Listeners collection, followed by a line terminator.
public override void WriteLine(char value)
Parameters
valueSystem.CharA character to write to the System.Diagnostics.Trace.Listeners collection.
WriteLine(Char[])
Writes an array of characters to the trace listeners in the System.Diagnostics.Trace.Listeners collection, followed by a line terminator.
public override void WriteLine(char[] buffer)
Parameters
bufferSystem.Char[]An array of characters to write to the System.Diagnostics.Trace.Listeners collection.
WriteLine(Char[], Int32, Int32)
Writes a subarray of characters to the trace listeners in the System.Diagnostics.Trace.Listeners collection, followed by a line terminator.
public override void WriteLine(char[] buffer, int index, int count)
Parameters
bufferSystem.Char[]An array of characters.
indexSystem.Int32The starting position within
bufferof the characters to write to the trace listeners in the System.Diagnostics.Trace.Listeners collection.countSystem.Int32The number of characters within
bufferto use.
Exceptions
- System.ArgumentNullException
bufferis null.- System.ArgumentOutOfRangeException
indexorcountis less than zero.-or-
The sum of
indexandcountis greater than the number of elements inbuffer.
WriteLine(Decimal)
Writes the value of the decimal's ToString() method to the trace listeners in the System.Diagnostics.Trace.Listeners collection, followed by a line terminator.
public override void WriteLine(decimal value)
Parameters
valueSystem.DecimalA decimal value to write to the System.Diagnostics.Trace.Listeners collection.
WriteLine(Double)
Writes the value of the double's ToString() method to the trace listeners in the System.Diagnostics.Trace.Listeners collection, followed by a line terminator.
public override void WriteLine(double value)
Parameters
valueSystem.DoubleA double value to write to the System.Diagnostics.Trace.Listeners collection.
WriteLine(Int32)
Writes the value of the Int32's ToString() method to the trace listeners in the System.Diagnostics.Trace.Listeners collection, followed by a line terminator.
public override void WriteLine(int value)
Parameters
valueSystem.Int32An Int32 value to write to the System.Diagnostics.Trace.Listeners collection.
WriteLine(Int64)
Writes the value of the Int64's ToString() method to the trace listeners in the System.Diagnostics.Trace.Listeners collection, followed by a line terminator.
public override void WriteLine(long value)
Parameters
valueSystem.Int64An Int64 value to write to the System.Diagnostics.Trace.Listeners collection.
WriteLine(Object)
Writes the value of the object's ToString() method to the trace listeners in the System.Diagnostics.Trace.Listeners collection, followed by a line terminator.
public override void WriteLine(object value)
Parameters
valueSystem.ObjectAn object value to write to the System.Diagnostics.Trace.Listeners collection.
WriteLine(Single)
Writes the value of the float's ToString() method to the trace listeners in the System.Diagnostics.Trace.Listeners collection, followed by a line terminator.
public override void WriteLine(float value)
Parameters
valueSystem.SingleA float value to write to the System.Diagnostics.Trace.Listeners collection.
WriteLine(String)
Writes a message to the trace listeners in the System.Diagnostics.Trace.Listeners collection, followed by a line terminator.
public override void WriteLine(string value)
Parameters
valueSystem.StringA message to write to the System.Diagnostics.Trace.Listeners collection.
WriteLine(String, Object)
Writes a formatted string to the trace listeners in the System.Diagnostics.Trace.Listeners collection, using the same semantics as the System.String.Format(System.IFormatProvider,System.String,System.Object) method, and followed by a line terminator.
public override void WriteLine(string format, object arg0)
Parameters
formatSystem.StringA composite format string.
arg0System.ObjectThe object to format.
Exceptions
- System.ArgumentNullException
formatis null orarg0is null.- System.FormatException
formatis invalid.-or-
The index of a
formatitem is not zero.
WriteLine(String, Object, Object)
Writes a formatted string to the trace listeners in the System.Diagnostics.Trace.Listeners collection, using the same semantics as the System.String.Format(System.IFormatProvider,System.String,System.Object,System.Object) method, and followed by a line terminator.
public override void WriteLine(string format, object arg0, object arg1)
Parameters
formatSystem.StringA composite format string.
arg0System.ObjectThe first object to format.
arg1System.ObjectThe second object to format.
Exceptions
- System.ArgumentNullException
formatis null orarg0is null orarg1is null.- System.FormatException
formatis invalid.-or-
The index of a
formatitem is less than zero, or greater than or equal to two.
WriteLine(String, Object, Object, Object)
Writes a formatted string to the trace listeners in the System.Diagnostics.Trace.Listeners collection, using the same semantics as the System.String.Format(System.IFormatProvider,System.String,System.Object,System.Object,System.Object) method, and followed by a line terminator.
public override void WriteLine(string format, object arg0, object arg1, object arg2)
Parameters
formatSystem.StringA composite format string.
arg0System.ObjectThe first object to format.
arg1System.ObjectThe second object to format.
arg2System.ObjectThe third object to format.
Exceptions
- System.ArgumentNullException
formatis null orarg0is null orarg1is null orarg2is null.- System.FormatException
formatis invalid.-or-
The index of a
formatitem is less than zero, or greater than or equal to three.
WriteLine(String, Object[])
Writes a formatted string to the trace listeners in the System.Diagnostics.Trace.Listeners collection, using the same semantics as the System.String.Format(System.IFormatProvider,System.String,System.Object[]) method, followed by a line terminator.
public override void WriteLine(string format, params object[] arg)
Parameters
formatSystem.StringA composite format string.
argSystem.Object[]An object array that contains zero or more objects to format.
Exceptions
- System.ArgumentNullException
formatorargis null.- System.FormatException
formatis invalid.-or-
The index of a
formatitem is less than zero, or greater than or equal to the length of theargarray.
WriteLine(UInt32)
Writes the value of the UInt32's ToString() method to the trace listeners in the System.Diagnostics.Trace.Listeners collection, followed by a line terminator.
[CLSCompliant(false)]
public override void WriteLine(uint value)
Parameters
valueSystem.UInt32A UInt32 value to write to the System.Diagnostics.Trace.Listeners collection.
WriteLine(UInt64)
Writes the value of the UInt64's ToString() method to the trace listeners in the System.Diagnostics.Trace.Listeners collection, followed by a line terminator.
[CLSCompliant(false)]
public override void WriteLine(ulong value)
Parameters
valueSystem.UInt64A UInt64 value to write to the System.Diagnostics.Trace.Listeners collection.
WriteLineAsync()
Writes a line terminator to the trace listeners in the System.Diagnostics.Trace.Listeners collection, asynchronously.
public override Task WriteLineAsync()
Returns
- System.Threading.Tasks.Task
A Task that represents the asynchronous write operation.
WriteLineAsync(Char)
Writes a character to the trace listeners in the System.Diagnostics.Trace.Listeners collection, followed by a line terminator, asynchronously.
public override Task WriteLineAsync(char value)
Parameters
valueSystem.CharA character to write to the System.Diagnostics.Trace.Listeners collection.
Returns
- System.Threading.Tasks.Task
A Task that represents the asynchronous write operation.
WriteLineAsync(Char[], Int32, Int32)
Writes a subarray of characters to the trace listeners in the System.Diagnostics.Trace.Listeners collection, followed by a line terminator, asynchronously.
public override Task WriteLineAsync(char[] buffer, int index, int count)
Parameters
bufferSystem.Char[]An array of characters.
indexSystem.Int32The starting position within
bufferof the characters to write to the System.Diagnostics.Trace.Listeners.countSystem.Int32The number of characters within
bufferto use.
Returns
- System.Threading.Tasks.Task
A Task that represents the asynchronous write operation.
Exceptions
- System.ArgumentNullException
An System.ArgumentNullException will be thrown if
bufferis null.- System.ArgumentOutOfRangeException
An System.ArgumentNullException will be thrown if
indexorcountis less than zero.-or-
The sum of
indexandcountis greater than the number of elements inbuffer.