XmlWriterSettings.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //
  2. // XmlWriterSettings.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // (C) 2004 Novell Inc.
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if NET_2_0
  30. using System;
  31. using System.IO;
  32. using System.Text;
  33. using System.Xml.Schema;
  34. namespace System.Xml
  35. {
  36. public sealed class XmlWriterSettings
  37. {
  38. private bool checkCharacters;
  39. private bool closeOutput;
  40. private ConformanceLevel conformance;
  41. private Encoding encoding;
  42. private bool indent;
  43. private string indentChars;
  44. private string newLineChars;
  45. private bool newLineOnAttributes;
  46. private NewLineHandling newLineHandling;
  47. private bool omitXmlDeclaration;
  48. private XmlOutputMethod outputMethod;
  49. public XmlWriterSettings ()
  50. {
  51. Reset ();
  52. }
  53. private XmlWriterSettings (XmlWriterSettings org)
  54. {
  55. checkCharacters = org.checkCharacters;
  56. closeOutput = org.closeOutput;
  57. conformance = org.conformance;
  58. encoding = org.encoding;
  59. indent = org.indent;
  60. indentChars = org.indentChars;
  61. newLineChars = org.newLineChars;
  62. newLineOnAttributes = org.newLineOnAttributes;
  63. newLineHandling = org.newLineHandling;
  64. outputMethod = org.outputMethod;
  65. omitXmlDeclaration = org.omitXmlDeclaration;
  66. }
  67. public XmlWriterSettings Clone ()
  68. {
  69. return new XmlWriterSettings (this);
  70. }
  71. public void Reset ()
  72. {
  73. checkCharacters = true;
  74. closeOutput = false; // ? not documented
  75. conformance = ConformanceLevel.Document;
  76. encoding = Encoding.UTF8;
  77. indent = false;
  78. indentChars = " ";
  79. // LAMESPEC: MS.NET says it is "\r\n", but it is silly decision.
  80. newLineChars = Environment.NewLine;
  81. newLineOnAttributes = false;
  82. newLineHandling = NewLineHandling.None;
  83. omitXmlDeclaration = false;
  84. outputMethod = XmlOutputMethod.AutoDetect;
  85. }
  86. // It affects only on XmlTextWriter
  87. public bool CheckCharacters {
  88. get { return checkCharacters; }
  89. set { checkCharacters = value; }
  90. }
  91. // It affects only on XmlTextWriter
  92. public bool CloseOutput {
  93. get { return closeOutput; }
  94. set { closeOutput = value; }
  95. }
  96. // It affects only on XmlTextWriter????
  97. public ConformanceLevel ConformanceLevel {
  98. get { return conformance; }
  99. set { conformance = value; }
  100. }
  101. public Encoding Encoding {
  102. get { return encoding; }
  103. set { encoding = value; }
  104. }
  105. // It affects only on XmlTextWriter
  106. public bool Indent {
  107. get { return indent; }
  108. set { indent = value; }
  109. }
  110. // It affects only on XmlTextWriter
  111. public string IndentChars {
  112. get { return indentChars; }
  113. set { indentChars = value; }
  114. }
  115. // It affects only on XmlTextWriter
  116. public string NewLineChars {
  117. get { return newLineChars; }
  118. set { newLineChars = value; }
  119. }
  120. // It affects only on XmlTextWriter
  121. public bool NewLineOnAttributes {
  122. get { return newLineOnAttributes; }
  123. set { newLineOnAttributes = value; }
  124. }
  125. // It affects only on XmlTextWriter
  126. public NewLineHandling NewLineHandling {
  127. get { return newLineHandling; }
  128. set { newLineHandling = value; }
  129. }
  130. // It affects only on XmlTextWriter
  131. public bool OmitXmlDeclaration {
  132. get { return omitXmlDeclaration; }
  133. set { omitXmlDeclaration = value; }
  134. }
  135. // does it affect only on XmlTextWriter?
  136. public XmlOutputMethod OutputMethod {
  137. get { return outputMethod; }
  138. //set { outputMethod = value; }
  139. }
  140. }
  141. }
  142. #endif