XmlSerializationWriter.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. //
  2. // System.Xml.Serialization.XmlSerializationWriter.cs
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2002
  8. //
  9. using System;
  10. using System.Collections;
  11. using System.Xml;
  12. namespace System.Xml.Serialization {
  13. public abstract class XmlSerializationWriter {
  14. #region Fields
  15. ArrayList namespaces;
  16. XmlWriter writer;
  17. #endregion // Fields
  18. #region Constructors
  19. [MonoTODO]
  20. protected XmlSerializationWriter ()
  21. {
  22. throw new NotImplementedException ();
  23. }
  24. #endregion // Constructors
  25. #region Properties
  26. protected ArrayList Namespaces {
  27. get { return namespaces; }
  28. set { namespaces = value; }
  29. }
  30. protected XmlWriter Writer {
  31. get { return writer; }
  32. set { writer = value; }
  33. }
  34. #endregion // Properties
  35. #region Methods
  36. [MonoTODO ("Implement")]
  37. protected void AddWriteCallback (Type type, string typeName, string typeNs, XmlSerializationWriteCallback callback)
  38. {
  39. throw new NotImplementedException ();
  40. }
  41. protected Exception CreateMismatchChoiceException (string value, string elementName, string enumValue)
  42. {
  43. string message = String.Format ("Value of {0} mismatches the type of {1}, you need to set it to {2}.", elementName, value, enumValue);
  44. return new InvalidOperationException (message);
  45. }
  46. protected Exception CreateUnknownAnyElementException (string name, string ns)
  47. {
  48. string message = String.Format ("The XML element named '{0}' from namespace '{1}' was not expected. The XML element name and namespace must match those provided via XmlAnyElementAttribute(s).", name, ns);
  49. return new InvalidOperationException (message);
  50. }
  51. protected Exception CreateUnknownTypeException (object o)
  52. {
  53. return CreateUnknownTypeException (o.GetType ());
  54. }
  55. protected Exception CreateUnknownTypeException (Type type)
  56. {
  57. string message = String.Format ("The type {0} may not be used in this context.", type);
  58. return new InvalidOperationException (message);
  59. }
  60. [MonoTODO ("Implement")]
  61. protected static byte[] FromByteArrayBase64 (byte[] value)
  62. {
  63. throw new NotImplementedException ();
  64. }
  65. [MonoTODO ("Implement")]
  66. protected static string FromByteArrayHex (byte[] value)
  67. {
  68. throw new NotImplementedException ();
  69. }
  70. protected static string FromChar (char value)
  71. {
  72. return ((int) value).ToString ();
  73. }
  74. [MonoTODO ("Implement")]
  75. protected static string FromDate (DateTime value)
  76. {
  77. throw new NotImplementedException ();
  78. }
  79. [MonoTODO ("Implement")]
  80. protected static string FromDateTime (DateTime value)
  81. {
  82. throw new NotImplementedException ();
  83. }
  84. [MonoTODO ("Implement")]
  85. protected static string FromEnum (long value, string[] values, long[] ids)
  86. {
  87. throw new NotImplementedException ();
  88. }
  89. [MonoTODO ("Implement")]
  90. protected static string FromTime (DateTime value)
  91. {
  92. throw new NotImplementedException ();
  93. }
  94. [MonoTODO ("Implement")]
  95. protected static string FromXmlName (string name)
  96. {
  97. throw new NotImplementedException ();
  98. }
  99. [MonoTODO ("Implement")]
  100. protected static string FromXmlNCName (string ncName)
  101. {
  102. throw new NotImplementedException ();
  103. }
  104. [MonoTODO ("Implement")]
  105. protected static string FromXmlNmToken (string nmToken)
  106. {
  107. throw new NotImplementedException ();
  108. }
  109. [MonoTODO ("Implement")]
  110. protected static string FromXmlNmTokens (string nmTokens)
  111. {
  112. throw new NotImplementedException ();
  113. }
  114. [MonoTODO ("Implement")]
  115. protected string FromXmlQualifiedName (XmlQualifiedName xmlQualifiedName)
  116. {
  117. throw new NotImplementedException ();
  118. }
  119. protected abstract void InitCallbacks ();
  120. [MonoTODO ("Implement")]
  121. protected void TopLevelElement ()
  122. {
  123. throw new NotImplementedException ();
  124. }
  125. protected void WriteAttribute (string localName, byte[] value)
  126. {
  127. WriteAttribute (localName, String.Empty, value);
  128. }
  129. protected void WriteAttribute (string localName, string value)
  130. {
  131. WriteAttribute (String.Empty, localName, String.Empty, value);
  132. }
  133. [MonoTODO ("Implement")]
  134. protected void WriteAttribute (string localName, string ns, byte[] value)
  135. {
  136. throw new NotImplementedException ();
  137. }
  138. protected void WriteAttribute (string localName, string ns, string value)
  139. {
  140. WriteAttribute (String.Empty, localName, ns, value);
  141. }
  142. [MonoTODO ("Implement")]
  143. protected void WriteAttribute (string prefix, string localName, string ns, string value)
  144. {
  145. throw new NotImplementedException ();
  146. }
  147. [MonoTODO ("Implement")]
  148. protected void WriteElementEncoded (XmlNode node, string name, string ns, bool isNullable, bool any)
  149. {
  150. throw new NotImplementedException ();
  151. }
  152. [MonoTODO ("Implement")]
  153. protected void WriteElementLiteral (XmlNode node, string name, string ns, bool isNullable, bool any)
  154. {
  155. throw new NotImplementedException ();
  156. }
  157. [MonoTODO ("Implement")]
  158. protected void WriteElementQualifiedName (string localName, XmlQualifiedName value)
  159. {
  160. throw new NotImplementedException ();
  161. }
  162. [MonoTODO ("Implement")]
  163. protected void WriteElementQualifiedName (string localName, string ns, XmlQualifiedName value)
  164. {
  165. throw new NotImplementedException ();
  166. }
  167. [MonoTODO ("Implement")]
  168. protected void WriteElementQualifiedName (string localName, XmlQualifiedName value, XmlQualifiedName xsiType)
  169. {
  170. throw new NotImplementedException ();
  171. }
  172. [MonoTODO ("Implement")]
  173. protected void WriteElementQualifiedName (string localName, string ns, XmlQualifiedName value, XmlQualifiedName xsiType)
  174. {
  175. throw new NotImplementedException ();
  176. }
  177. protected void WriteElementString (string localName, string value)
  178. {
  179. WriteElementString (localName, String.Empty, value, null);
  180. }
  181. protected void WriteElementString (string localName, string ns, string value)
  182. {
  183. WriteElementString (localName, ns, value, null);
  184. }
  185. protected void WriteElementString (string localName, string value, XmlQualifiedName xsiType)
  186. {
  187. WriteElementString (localName, String.Empty, value, xsiType);
  188. }
  189. [MonoTODO ("Implement")]
  190. protected void WriteElementString (string localName, string ns, string value, XmlQualifiedName xsiType)
  191. {
  192. throw new NotImplementedException ();
  193. }
  194. protected void WriteElementStringRaw (string localName, byte[] value)
  195. {
  196. WriteElementStringRaw (localName, String.Empty, value, null);
  197. }
  198. protected void WriteElementStringRaw (string localName, string value)
  199. {
  200. WriteElementStringRaw (localName, String.Empty, value, null);
  201. }
  202. protected void WriteElementStringRaw (string localName, byte[] value, XmlQualifiedName xsiType)
  203. {
  204. WriteElementStringRaw (localName, String.Empty, value, xsiType);
  205. }
  206. protected void WriteElementStringRaw (string localName, string ns, byte[] value)
  207. {
  208. WriteElementStringRaw (localName, ns, value, null);
  209. }
  210. protected void WriteElementStringRaw (string localName, string ns, string value)
  211. {
  212. WriteElementStringRaw (localName, ns, value, null);
  213. }
  214. protected void WriteElementStringRaw (string localName, string value, XmlQualifiedName xsiType)
  215. {
  216. WriteElementStringRaw (localName, String.Empty, value, null);
  217. }
  218. [MonoTODO ("Implement")]
  219. protected void WriteElementStringRaw (string localName, string ns, byte[] value, XmlQualifiedName xsiType)
  220. {
  221. throw new NotImplementedException ();
  222. }
  223. [MonoTODO ("Implement")]
  224. protected void WriteElementStringRaw (string localName, string ns, string value, XmlQualifiedName xsiType)
  225. {
  226. throw new NotImplementedException ();
  227. }
  228. protected void WriteEmptyTag (string name)
  229. {
  230. WriteEmptyTag (name, String.Empty);
  231. }
  232. [MonoTODO ("Implement")]
  233. protected void WriteEmptyTag (string name, string ns)
  234. {
  235. throw new NotImplementedException ();
  236. }
  237. protected void WriteEndElement ()
  238. {
  239. WriteEndElement (null);
  240. }
  241. [MonoTODO ("Implement")]
  242. protected void WriteEndElement (object o)
  243. {
  244. throw new NotImplementedException ();
  245. }
  246. [MonoTODO ("Implement")]
  247. protected void WriteId (object o)
  248. {
  249. throw new NotImplementedException ();
  250. }
  251. [MonoTODO ("Implement")]
  252. protected void WriteNullableQualifiedNameEncoded (string name, string ns, XmlQualifiedName value, XmlQualifiedName xsiType)
  253. {
  254. throw new NotImplementedException ();
  255. }
  256. [MonoTODO ("Implement")]
  257. protected void WriteNullableQualifiedNameLiteral (string name, string ns, XmlQualifiedName value)
  258. {
  259. throw new NotImplementedException ();
  260. }
  261. [MonoTODO ("Implement")]
  262. protected void WriteNullableStringEncoded (string name, string ns, string value, XmlQualifiedName xsiType)
  263. {
  264. throw new NotImplementedException ();
  265. }
  266. [MonoTODO ("Implement")]
  267. protected void WriteNullableStringEncodedRaw (string name, string ns, byte[] value, XmlQualifiedName xsiType)
  268. {
  269. throw new NotImplementedException ();
  270. }
  271. [MonoTODO ("Implement")]
  272. protected void WriteNullableStringEncodedRaw (string name, string ns, string value, XmlQualifiedName xsiType)
  273. {
  274. throw new NotImplementedException ();
  275. }
  276. [MonoTODO ("Implement")]
  277. protected void WriteNullableStringLiteral (string name, string ns, string value)
  278. {
  279. throw new NotImplementedException ();
  280. }
  281. [MonoTODO ("Implement")]
  282. protected void WriteNullableStringLiteralRaw (string name, string ns, byte[] value)
  283. {
  284. throw new NotImplementedException ();
  285. }
  286. [MonoTODO ("Implement")]
  287. protected void WriteNullableStringLiteralRaw (string name, string ns, string value)
  288. {
  289. throw new NotImplementedException ();
  290. }
  291. protected void WriteNullTagEncoded (string name)
  292. {
  293. WriteNullTagEncoded (name, String.Empty);
  294. }
  295. [MonoTODO ("Implement")]
  296. protected void WriteNullTagEncoded (string name, string ns)
  297. {
  298. throw new NotImplementedException ();
  299. }
  300. protected void WriteNullTagLiteral (string name)
  301. {
  302. WriteNullTagLiteral (name, String.Empty);
  303. }
  304. [MonoTODO ("Implement")]
  305. protected void WriteNullTagLiteral (string name, string ns)
  306. {
  307. throw new NotImplementedException ();
  308. }
  309. protected void WritePotentiallyReferencingElement (string n, string ns, object o)
  310. {
  311. WritePotentiallyReferencingElement (n, ns, o, null, false, false);
  312. }
  313. protected void WritePotentiallyReferencingElement (string n, string ns, object o, Type ambientType)
  314. {
  315. WritePotentiallyReferencingElement (n, ns, o, ambientType, false, false);
  316. }
  317. protected void WritePotentiallyReferencingElement (string n, string ns, object o, Type ambientType, bool suppressReference)
  318. {
  319. WritePotentiallyReferencingElement (n, ns, o, ambientType, suppressReference, false);
  320. }
  321. [MonoTODO ("Implement")]
  322. protected void WritePotentiallyReferencingElement (string n, string ns, object o, Type ambientType, bool suppressReference, bool isNullable)
  323. {
  324. throw new NotImplementedException ();
  325. }
  326. [MonoTODO ("Implement")]
  327. protected void WriteReferencedElements ()
  328. {
  329. throw new NotImplementedException ();
  330. }
  331. protected void WriteReferencingElement (string n, string ns, object o)
  332. {
  333. WriteReferencingElement (n, ns, o, false);
  334. }
  335. [MonoTODO ("Implement")]
  336. protected void WriteReferencingElement (string n, string ns, object o, bool isNullable)
  337. {
  338. throw new NotImplementedException ();
  339. }
  340. [MonoTODO ("Implement")]
  341. protected void WriteSerializable (IXmlSerializable serializable, string name, string ns, bool isNullable)
  342. {
  343. throw new NotImplementedException ();
  344. }
  345. protected void WriteStartDocument ()
  346. {
  347. Writer.WriteStartDocument ();
  348. }
  349. protected void WriteStartElement (string name)
  350. {
  351. WriteStartElement (name, String.Empty, null, false);
  352. }
  353. protected void WriteStartElement (string name, string ns)
  354. {
  355. WriteStartElement (name, ns, null, false);
  356. }
  357. protected void WriteStartElement (string name, string ns, bool writePrefixed)
  358. {
  359. WriteStartElement (name, ns, null, writePrefixed);
  360. }
  361. protected void WriteStartElement (string name, string ns, object o)
  362. {
  363. WriteStartElement (name, ns, o, false);
  364. }
  365. [MonoTODO ("Implement")]
  366. protected void WriteStartElement (string name, string ns, object o, bool writePrefixed)
  367. {
  368. throw new NotImplementedException ();
  369. }
  370. [MonoTODO ("Implement")]
  371. protected void WriteTypedPrimitive (string name, string ns, object o, bool xsiType)
  372. {
  373. throw new NotImplementedException ();
  374. }
  375. protected void WriteValue (byte[] value)
  376. {
  377. Writer.WriteBase64 (value, 0, value.Length);
  378. }
  379. protected void WriteValue (string value)
  380. {
  381. Writer.WriteString (value);
  382. }
  383. [MonoTODO ("Implement")]
  384. protected void WriteXmlAttribute (XmlNode node)
  385. {
  386. throw new NotImplementedException ();
  387. }
  388. [MonoTODO ("Implement")]
  389. protected void WriteXmlAttribute (XmlNode node, object container)
  390. {
  391. throw new NotImplementedException ();
  392. }
  393. [MonoTODO ("Implement")]
  394. protected void WriteXsiType (string name, string ns)
  395. {
  396. throw new NotImplementedException ();
  397. }
  398. #endregion
  399. }
  400. }