2 // XmlWriterSettings.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // (C) 2004 Novell Inc.
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 using System.Xml.Schema;
40 public sealed class XmlWriterSettings
42 private bool checkCharacters;
43 private bool closeOutput;
44 private ConformanceLevel conformance;
45 private Encoding encoding;
47 private string indentChars;
48 private string newLineChars;
49 private bool newLineOnAttributes;
50 private NewLineHandling newLineHandling;
51 private bool omitXmlDeclaration;
52 private XmlOutputMethod outputMethod;
54 public XmlWriterSettings ()
59 public XmlWriterSettings Clone ()
61 return (XmlWriterSettings) MemberwiseClone ();
64 // This might better be rewrite to "examine two settings and return the existing one or new one if required".
65 internal void MergeFrom (XmlWriterSettings other)
67 CloseOutput |= other.CloseOutput;
68 OmitXmlDeclaration |= other.OmitXmlDeclaration;
69 if (ConformanceLevel == ConformanceLevel.Auto)
70 ConformanceLevel = other.ConformanceLevel;
75 checkCharacters = true;
76 closeOutput = false; // ? not documented
77 conformance = ConformanceLevel.Document;
78 encoding = Encoding.UTF8;
81 // LAMESPEC: MS.NET says it is "\r\n", but it is silly decision.
82 newLineChars = Environment.NewLine;
83 newLineOnAttributes = false;
84 newLineHandling = NewLineHandling.None;
85 omitXmlDeclaration = false;
86 outputMethod = XmlOutputMethod.AutoDetect;
89 // It affects only on XmlTextWriter
90 public bool CheckCharacters {
91 get { return checkCharacters; }
92 set { checkCharacters = value; }
95 // It affects only on XmlTextWriter
96 public bool CloseOutput {
97 get { return closeOutput; }
98 set { closeOutput = value; }
101 // It affects only on XmlTextWriter????
102 public ConformanceLevel ConformanceLevel {
103 get { return conformance; }
104 set { conformance = value; }
107 public Encoding Encoding {
108 get { return encoding; }
109 set { encoding = value; }
112 // It affects only on XmlTextWriter
114 get { return indent; }
115 set { indent = value; }
118 // It affects only on XmlTextWriter
119 public string IndentChars {
120 get { return indentChars; }
121 set { indentChars = value; }
124 // It affects only on XmlTextWriter
125 public string NewLineChars {
126 get { return newLineChars; }
129 throw new ArgumentNullException ("value");
130 newLineChars = value;
134 // It affects only on XmlTextWriter
135 public bool NewLineOnAttributes {
136 get { return newLineOnAttributes; }
137 set { newLineOnAttributes = value; }
140 // It affects only on XmlTextWriter
141 public NewLineHandling NewLineHandling {
142 get { return newLineHandling; }
143 set { newLineHandling = value; }
146 // It affects only on XmlTextWriter
147 public bool OmitXmlDeclaration {
148 get { return omitXmlDeclaration; }
149 set { omitXmlDeclaration = value; }
152 // does it affect only on XmlTextWriter?
153 public XmlOutputMethod OutputMethod {
154 get { return outputMethod; }
155 //set { outputMethod = value; }
158 #if MOONLIGHT || MOBILE || NET_4_0
163 NamespaceHandling NamespaceHandling { get; set; }