/
CustomWriter.cs
184 lines (151 loc) · 4.66 KB
/
CustomWriter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using System.Xml;
namespace XmlCoreTest.Common
{
public class CustomWriter : XmlWriter
{
private XmlWriter _writer = null;
public CustomWriter(Stream strm, XmlWriterSettings xws)
{
_writer = XmlWriter.Create(strm, xws);
}
public CustomWriter(string filename, XmlWriterSettings xws)
{
_writer = XmlWriter.Create(FilePathUtil.getStream(filename), xws);
}
public CustomWriter(StringWriter sw, XmlWriterSettings xws)
{
_writer = XmlWriter.Create(sw, xws);
}
public override void WriteStartDocument()
{
_writer.WriteStartDocument();
}
public override void WriteStartDocument(bool standalone)
{
_writer.WriteStartDocument(standalone);
}
public override void WriteEndDocument()
{
_writer.WriteEndDocument();
}
public override void WriteDocType(string name, string pubid, string sysid, string subset)
{
_writer.WriteDocType(name, pubid, sysid, subset);
}
public override void WriteStartElement(string prefix, string localName, string ns)
{
_writer.WriteStartElement(prefix, localName, ns);
}
public override void WriteEndElement()
{
_writer.WriteEndElement();
}
public override void WriteFullEndElement()
{
_writer.WriteFullEndElement();
}
public override void WriteStartAttribute(string prefix, string localName, string ns)
{
_writer.WriteStartAttribute(prefix, localName, ns);
}
public override void WriteEndAttribute()
{
_writer.WriteEndAttribute();
}
public override void WriteCData(string text)
{
_writer.WriteCData(text);
}
public override void WriteComment(string text)
{
_writer.WriteComment(text);
}
public override void WriteProcessingInstruction(string name, string text)
{
_writer.WriteProcessingInstruction(name, text);
}
public override void WriteEntityRef(string name)
{
_writer.WriteEntityRef(name);
}
public override void WriteCharEntity(char ch)
{
_writer.WriteCharEntity(ch);
}
public override void WriteWhitespace(string ws)
{
_writer.WriteWhitespace(ws);
}
public override void WriteString(string text)
{
_writer.WriteString(text);
}
public override void WriteSurrogateCharEntity(char lowChar, char highChar)
{
_writer.WriteSurrogateCharEntity(lowChar, highChar);
}
public override void WriteChars(char[] buffer, int index, int count)
{
_writer.WriteChars(buffer, index, count);
}
public override void WriteRaw(char[] buffer, int index, int count)
{
_writer.WriteRaw(buffer, index, count);
}
public override void WriteRaw(string data)
{
_writer.WriteRaw(data);
}
public override void WriteBase64(byte[] buffer, int index, int count)
{
_writer.WriteBase64(buffer, index, count);
}
public override WriteState WriteState
{
get
{
return _writer.WriteState;
}
}
// XmlSpace and XmlLang are virtual, so custom writer does not need to override them.
// But the virtual impln returns Default and empty string respectively, which breaks many writer API tests, hence they are overridden here.
public override XmlSpace XmlSpace
{
get
{
return _writer.XmlSpace;
}
}
public override string XmlLang
{
get
{
return _writer.XmlLang;
}
}
public override void Close()
{
Dispose(disposing:true);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
_writer.Dispose();
}
base.Dispose(disposing);
}
public override void Flush()
{
_writer.Flush();
}
public override string LookupPrefix(string ns)
{
return _writer.LookupPrefix(ns);
}
}
}