ca039a1740ee4313dbff8475e75f2b7e99a6625e
[mono.git] / mcs / class / referencesource / System.Data.SqlXml / System / Xml / Xsl / XsltOld / TextOutput.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="TextOutput.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>                                                                
5 // <owner current="true" primary="true">[....]</owner>
6 //------------------------------------------------------------------------------
7
8 namespace System.Xml.Xsl.XsltOld {
9     using Res = System.Xml.Utils.Res;
10     using System;
11     using System.IO;
12     using System.Xml;
13     using System.Xml.XPath;
14     using System.Text;
15
16     internal class TextOutput : SequentialOutput {
17         private TextWriter writer;
18
19         internal TextOutput(Processor processor, Stream stream)
20             : base(processor) 
21         {
22             if (stream == null) {
23                 throw new ArgumentNullException("stream");
24             }
25
26             this.encoding = processor.Output.Encoding;
27             this.writer   = new StreamWriter(stream, this.encoding);
28         }
29
30         internal TextOutput(Processor processor, TextWriter writer)
31             : base(processor) 
32         {
33             if (writer == null) {
34                 throw new ArgumentNullException("writer");
35             }
36
37             this.encoding = writer.Encoding;
38             this.writer   = writer;
39         }
40
41         internal override void Write(char outputChar) {
42             this.writer.Write(outputChar);
43         }
44
45         internal override void Write(string outputText) {
46             this.writer.Write(outputText);
47         }
48
49         internal override void Close() {
50             this.writer.Flush();
51             this.writer = null;
52         }
53     }
54 }