Table of Contents

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.Object
System.MarshalByRefObject
System.IO.TextWriter
MultiTextWriter
Implements
System.IDisposable
Inherited Members
System.IO.TextWriter.CoreNewLine
System.IO.TextWriter.Null
System.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.FormatProvider
System.IO.TextWriter.NewLine
System.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

inWriteStrategies System.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

inWriteStrategies System.Collections.Generic.IReadOnlyCollection<IWriteStrategy>

A collection of write strategies.

inFormatProvider System.IFormatProvider

An 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

obj System.Object

The object to compare with the current instance.

Returns

System.Boolean

true if obj and 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

value System.Boolean

A 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

value System.Char

A 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

buffer System.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

buffer System.Char[]

An array of characters.

index System.Int32

The starting position within buffer of the characters to write to the trace listeners in the System.Diagnostics.Trace.Listeners collection.

count System.Int32

The number of characters within buffer to use.

Exceptions

System.ArgumentNullException

buffer is null.

System.ArgumentOutOfRangeException

index or count is less than zero.

-or-

The sum of index and count is greater than the number of elements in buffer.

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

value System.Decimal

A 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

value System.Double

A 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

value System.Int32

An 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

value System.Int64

An 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

value System.Object

An 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

value System.Single

A 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

value System.String

A 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

format System.String

A composite format string.

arg0 System.Object

The object to format.

Exceptions

System.ArgumentNullException

format is null or arg0 is null.

System.FormatException

format is invalid.

-or-

The index of a format item 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

format System.String

A composite format string.

arg0 System.Object

The first object to format.

arg1 System.Object

The second object to format.

Exceptions

System.ArgumentNullException

format is null or arg0 is null or arg1 is null.

System.FormatException

format is invalid.

-or-

The index of a format item 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

format System.String

A composite format string.

arg0 System.Object

The first object to format.

arg1 System.Object

The second object to format.

arg2 System.Object

The third object to format.

Exceptions

System.ArgumentNullException

format is null or arg0 is null or arg1 is null or arg2 is null.

System.FormatException

format is invalid.

-or-

The index of a format item 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

format System.String

A composite format string.

arg System.Object[]

An object array that contains zero or more objects to format.

Exceptions

System.ArgumentNullException

format or arg is null.

System.FormatException

format is invalid.

-or-

The index of a format item is less than zero, or greater than or equal to the length of the arg array.

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

value System.UInt32

A 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

value System.UInt64

A 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

value System.Char

A 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

buffer System.Char[]

An array of characters.

index System.Int32

The starting position within buffer of the characters to write to the System.Diagnostics.Trace.Listeners.

count System.Int32

The number of characters within buffer to use.

Returns

System.Threading.Tasks.Task

A Task that represents the asynchronous write operation.

Exceptions

System.ArgumentNullException

buffer is null.

System.ArgumentOutOfRangeException

index or count is less than zero.

-or-

The sum of index and count is greater than the number of elements in buffer.

WriteAsync(String)

Writes a string to the trace listeners in the System.Diagnostics.Trace.Listeners collection asynchronously.

public override Task WriteAsync(string value)

Parameters

value System.String

The 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

value System.Boolean

A 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

value System.Char

A 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

buffer System.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

buffer System.Char[]

An array of characters.

index System.Int32

The starting position within buffer of the characters to write to the trace listeners in the System.Diagnostics.Trace.Listeners collection.

count System.Int32

The number of characters within buffer to use.

Exceptions

System.ArgumentNullException

buffer is null.

System.ArgumentOutOfRangeException

index or count is less than zero.

-or-

The sum of index and count is greater than the number of elements in buffer.

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

value System.Decimal

A 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

value System.Double

A 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

value System.Int32

An 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

value System.Int64

An 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

value System.Object

An 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

value System.Single

A 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

value System.String

A 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

format System.String

A composite format string.

arg0 System.Object

The object to format.

Exceptions

System.ArgumentNullException

format is null or arg0 is null.

System.FormatException

format is invalid.

-or-

The index of a format item 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

format System.String

A composite format string.

arg0 System.Object

The first object to format.

arg1 System.Object

The second object to format.

Exceptions

System.ArgumentNullException

format is null or arg0 is null or arg1 is null.

System.FormatException

format is invalid.

-or-

The index of a format item 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

format System.String

A composite format string.

arg0 System.Object

The first object to format.

arg1 System.Object

The second object to format.

arg2 System.Object

The third object to format.

Exceptions

System.ArgumentNullException

format is null or arg0 is null or arg1 is null or arg2 is null.

System.FormatException

format is invalid.

-or-

The index of a format item 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

format System.String

A composite format string.

arg System.Object[]

An object array that contains zero or more objects to format.

Exceptions

System.ArgumentNullException

format or arg is null.

System.FormatException

format is invalid.

-or-

The index of a format item is less than zero, or greater than or equal to the length of the arg array.

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

value System.UInt32

A 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

value System.UInt64

A 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

value System.Char

A 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

buffer System.Char[]

An array of characters.

index System.Int32

The starting position within buffer of the characters to write to the System.Diagnostics.Trace.Listeners.

count System.Int32

The number of characters within buffer to use.

Returns

System.Threading.Tasks.Task

A Task that represents the asynchronous write operation.

Exceptions

System.ArgumentNullException

An System.ArgumentNullException will be thrown if buffer is null.

System.ArgumentOutOfRangeException

An System.ArgumentNullException will be thrown if index or count is less than zero.

-or-

The sum of index and count is greater than the number of elements in buffer.

See Also

IWriteStrategy
System.IO.TextWriter