XmlWriterSettings.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // XmlWriterSettings.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // (C) 2004 Novell Inc.
  8. //
  9. #if NET_2_0
  10. using System;
  11. using System.IO;
  12. using System.Text;
  13. using System.Xml.Schema;
  14. namespace System.Xml
  15. {
  16. public sealed class XmlWriterSettings : ICloneable
  17. {
  18. private bool checkCharacters;
  19. private bool closeOutput;
  20. private ConformanceLevel conformance;
  21. private bool encodeXmlBinary;
  22. private Encoding encoding;
  23. private bool indent;
  24. private string indentChars;
  25. private string newLineChars;
  26. private bool newLineOnAttributes;
  27. private bool normalizeNewLines;
  28. private bool omitXmlDeclaration;
  29. public XmlWriterSettings ()
  30. {
  31. Reset ();
  32. }
  33. private XmlWriterSettings (XmlWriterSettings org)
  34. {
  35. checkCharacters = org.checkCharacters;
  36. closeOutput = org.closeOutput;
  37. conformance = org.conformance;
  38. encodeXmlBinary = org.encodeXmlBinary;
  39. encoding = org.encoding;
  40. indent = org.indent;
  41. indentChars = org.indentChars;
  42. newLineChars = org.newLineChars;
  43. newLineOnAttributes = org.newLineOnAttributes;
  44. normalizeNewLines = org.normalizeNewLines;
  45. omitXmlDeclaration = org.omitXmlDeclaration;
  46. }
  47. public event ValidationEventHandler ValidationEventHandler;
  48. public XmlWriterSettings Clone ()
  49. {
  50. return new XmlWriterSettings (this);
  51. }
  52. object ICloneable.Clone ()
  53. {
  54. return this.Clone ();
  55. }
  56. public void Reset ()
  57. {
  58. checkCharacters = true;
  59. closeOutput = false; // ? not documented
  60. conformance = ConformanceLevel.Document;
  61. encodeXmlBinary = false;
  62. encoding = Encoding.UTF8;
  63. indent = false;
  64. indentChars = " ";
  65. // LAMESPEC: MS.NET says it is "\r\n", but it is silly decision.
  66. newLineChars = Environment.NewLine;
  67. newLineOnAttributes = false;
  68. normalizeNewLines = true;
  69. omitXmlDeclaration = false;
  70. }
  71. public bool CheckCharacters {
  72. get { return checkCharacters; }
  73. set { checkCharacters = value; }
  74. }
  75. public bool CloseOutput {
  76. get { return closeOutput; }
  77. set { closeOutput = value; }
  78. }
  79. public ConformanceLevel ConformanceLevel {
  80. get { return conformance; }
  81. set { conformance = value; }
  82. }
  83. public bool EncodeXmlBinary {
  84. get { return encodeXmlBinary; }
  85. }
  86. public Encoding Encoding {
  87. get { return encoding; }
  88. }
  89. public bool Indent {
  90. get { return indent; }
  91. }
  92. public string IndentChars {
  93. get { return indentChars; }
  94. }
  95. public string NewLineChars {
  96. get { return newLineChars; }
  97. }
  98. public bool NewLineOnAttributes {
  99. get { return newLineOnAttributes; }
  100. }
  101. public bool NormalizeNewLines {
  102. get { return normalizeNewLines; }
  103. }
  104. public bool OmitXmlDeclaration {
  105. get { return omitXmlDeclaration; }
  106. }
  107. }
  108. }
  109. #endif