using System.Collections.Generic; using System.IO; using System.Text; namespace Chernobyl.TextWriters { /// /// This class is used to write text to /// several TextWriter's at once or treat several /// TextWrite as one. /// public class TextWriterCollection : TextWriter { /// /// Constructor. /// /// The TextWriters to write to. public TextWriterCollection(params TextWriter[] textWriters) { TextWriters = new List(); TextWriters.AddRange(textWriters); } /// /// Writes a line of text out to the contained TextWriters. /// /// The string to write to the TextWriters. public override void WriteLine(string value) { // append a newline and write the value out foreach(TextWriter tw in TextWriters) tw.WriteLine(value); } /// /// Writes the string to the contained TextWriters. /// /// The string to write to the TextWriters. public override void Write(string value) { foreach(TextWriter tw in TextWriters) tw.Write(value); } /// /// When overridden in a derived class, returns the /// in which the output is written. /// /// The encoding of the output. /// The Encoding in which the output is written. public override Encoding Encoding { get { return Encoding.ASCII; } } List TextWriters {get; set;} } }