XmlSerializationReader.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. //
  2. // System.Xml.Serialization.XmlSerializationReader.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 XmlSerializationReader {
  14. #region Fields
  15. XmlDocument document;
  16. XmlReader reader;
  17. #endregion
  18. [MonoTODO]
  19. protected XmlSerializationReader ()
  20. {
  21. throw new NotImplementedException ();
  22. }
  23. protected XmlDocument Document {
  24. get { return document; }
  25. }
  26. protected XmlReader Reader {
  27. get { return reader; }
  28. }
  29. #region Methods
  30. [MonoTODO ("Implement")]
  31. protected void AddFixup (XmlSerializationReader.CollectionFixup fixup)
  32. {
  33. throw new NotImplementedException ();
  34. }
  35. [MonoTODO ("Implement")]
  36. protected void AddFixup (XmlSerializationReader.Fixup fixup)
  37. {
  38. throw new NotImplementedException ();
  39. }
  40. [MonoTODO ("Implement")]
  41. protected void AddReadCallback (string name, string ns, Type type, XmlSerializationReadCallback read)
  42. {
  43. throw new NotImplementedException ();
  44. }
  45. [MonoTODO ("Implement")]
  46. protected void AddTarget (string id, object o)
  47. {
  48. throw new NotImplementedException ();
  49. }
  50. [MonoTODO ("Implement")]
  51. protected Exception CreateAbstractTypeException (string name, string ns)
  52. {
  53. throw new NotImplementedException ();
  54. }
  55. protected Exception CreateInvalidCastException (Type type, object value)
  56. {
  57. string message = String.Format ("Cannot assign object of type {0} to an object of type {1}.", value.GetType (), type);
  58. return new InvalidCastException (message);
  59. }
  60. protected Exception CreateReadOnlyCollectionException (string name)
  61. {
  62. string message = String.Format ("Could not serialize {0}. Default constructors are required for collections and enumerators.", name);
  63. return new InvalidOperationException (message);
  64. }
  65. protected Exception CreateUnknownConstantException (string value, Type enumType)
  66. {
  67. string message = String.Format ("'{0}' is not a valid value for {1}.", value, enumType);
  68. return new InvalidOperationException (message);
  69. }
  70. [MonoTODO ("Implement")]
  71. protected Exception CreateUnknownNodeException ()
  72. {
  73. throw new NotImplementedException ();
  74. }
  75. [MonoTODO ("Implement")]
  76. protected Exception CreateUnknownTypeException (XmlQualifiedName type)
  77. {
  78. throw new NotImplementedException ();
  79. }
  80. [MonoTODO ("Implement")]
  81. protected Array EnsureArrayIndex (Array a, int index, Type elementType)
  82. {
  83. throw new NotImplementedException ();
  84. }
  85. [MonoTODO ("Implement")]
  86. protected void FixupArrayRefs (object fixup)
  87. {
  88. throw new NotImplementedException ();
  89. }
  90. [MonoTODO ("Implement")]
  91. protected int GetArrayLength (string name, string ns)
  92. {
  93. throw new NotImplementedException ();
  94. }
  95. [MonoTODO ("Implement")]
  96. protected bool GetNullAttr ()
  97. {
  98. throw new NotImplementedException ();
  99. }
  100. [MonoTODO ("Implement")]
  101. protected object GetTarget (string id)
  102. {
  103. throw new NotImplementedException ();
  104. }
  105. [MonoTODO ("Implement")]
  106. protected XmlQualifiedName GetXsiType ()
  107. {
  108. throw new NotImplementedException ();
  109. }
  110. protected abstract void InitCallbacks ();
  111. protected abstract void InitIDs ();
  112. [MonoTODO ("Implement")]
  113. protected bool IsXmlnsAttribute (string name)
  114. {
  115. throw new NotImplementedException ();
  116. }
  117. [MonoTODO ("Implement")]
  118. protected void ParseWsdlArrayType (XmlAttribute attr)
  119. {
  120. throw new NotImplementedException ();
  121. }
  122. [MonoTODO ("Implement")]
  123. protected XmlQualifiedName ReadElementQualifiedName ()
  124. {
  125. throw new NotImplementedException ();
  126. }
  127. [MonoTODO ("Implement")]
  128. protected void ReadEndElement ()
  129. {
  130. throw new NotImplementedException ();
  131. }
  132. [MonoTODO ("Implement")]
  133. protected bool ReadNull ()
  134. {
  135. throw new NotImplementedException ();
  136. }
  137. [MonoTODO ("Implement")]
  138. protected XmlQualifiedName ReadNullableQualifiedName ()
  139. {
  140. throw new NotImplementedException ();
  141. }
  142. [MonoTODO ("Implement")]
  143. protected string ReadNullableString ()
  144. {
  145. throw new NotImplementedException ();
  146. }
  147. [MonoTODO ("Implement")]
  148. protected bool ReadReference (out string fixupReference)
  149. {
  150. throw new NotImplementedException ();
  151. }
  152. [MonoTODO ("Implement")]
  153. protected object ReadReferencedElement ()
  154. {
  155. throw new NotImplementedException ();
  156. }
  157. [MonoTODO ("Implement")]
  158. protected object ReadReferencedElement (string name, string ns)
  159. {
  160. throw new NotImplementedException ();
  161. }
  162. [MonoTODO ("Implement")]
  163. protected void ReadReferencedElements ()
  164. {
  165. throw new NotImplementedException ();
  166. }
  167. [MonoTODO ("Implement")]
  168. protected object ReadReferencingElement (out string fixupReference)
  169. {
  170. throw new NotImplementedException ();
  171. }
  172. [MonoTODO ("Implement")]
  173. protected object ReadReferencingElement (string name, string ns, out string fixupReference)
  174. {
  175. throw new NotImplementedException ();
  176. }
  177. [MonoTODO ("Implement")]
  178. protected object ReadReferencingElement (string name, string ns, bool elementCanBeType, out string fixupReference)
  179. {
  180. throw new NotImplementedException ();
  181. }
  182. [MonoTODO ("Implement")]
  183. protected IXmlSerializable ReadSerializable (IXmlSerializable serializable)
  184. {
  185. throw new NotImplementedException ();
  186. }
  187. [MonoTODO ("Implement")]
  188. protected string ReadString (string value)
  189. {
  190. throw new NotImplementedException ();
  191. }
  192. [MonoTODO ("Implement")]
  193. protected object ReadTypedPrimitive (XmlQualifiedName type)
  194. {
  195. throw new NotImplementedException ();
  196. }
  197. [MonoTODO ("Implement")]
  198. protected XmlNode ReadXmlNode (bool wrapped)
  199. {
  200. throw new NotImplementedException ();
  201. }
  202. [MonoTODO ("Implement")]
  203. protected void Referenced (object o)
  204. {
  205. throw new NotImplementedException ();
  206. }
  207. [MonoTODO ("Implement")]
  208. protected Array ShrinkArray (Array a, int length, Type elementType, bool isNullable)
  209. {
  210. throw new NotImplementedException ();
  211. }
  212. [MonoTODO ("Implement")]
  213. protected byte[] ToByteArrayBase64 (bool isNull)
  214. {
  215. throw new NotImplementedException ();
  216. }
  217. [MonoTODO ("Implement")]
  218. protected static byte[] ToByteArrayBase64 (string value)
  219. {
  220. throw new NotImplementedException ();
  221. }
  222. [MonoTODO ("Implement")]
  223. protected byte[] ToByteArrayHex (bool isNull)
  224. {
  225. throw new NotImplementedException ();
  226. }
  227. [MonoTODO ("Implement")]
  228. protected static byte[] ToByteArrayHex (string value)
  229. {
  230. throw new NotImplementedException ();
  231. }
  232. protected static char ToChar (string value)
  233. {
  234. return XmlCustomFormatter.ToChar (value);
  235. }
  236. protected static DateTime ToDate (string value)
  237. {
  238. return XmlCustomFormatter.ToDate (value);
  239. }
  240. protected static DateTime ToDateTime (string value)
  241. {
  242. return XmlCustomFormatter.ToDateTime (value);
  243. }
  244. [MonoTODO ("Implement")]
  245. protected static long ToEnum (string value, Hashtable h, string typeName)
  246. {
  247. throw new NotImplementedException ();
  248. }
  249. protected static DateTime ToTime (string value)
  250. {
  251. return XmlCustomFormatter.ToTime (value);
  252. }
  253. protected static string ToXmlName (string value)
  254. {
  255. return XmlCustomFormatter.ToXmlName (value);
  256. }
  257. protected static string ToXmlNCName (string value)
  258. {
  259. return XmlCustomFormatter.ToXmlNCName (value);
  260. }
  261. protected static string ToXmlNmToken (string value)
  262. {
  263. return XmlCustomFormatter.ToXmlNmToken (value);
  264. }
  265. protected static string ToXmlNmTokens (string value)
  266. {
  267. return XmlCustomFormatter.ToXmlNmTokens (value);
  268. }
  269. [MonoTODO ("Implement")]
  270. protected XmlQualifiedName ToXmlQualifiedName (string value)
  271. {
  272. throw new NotImplementedException ();
  273. }
  274. [MonoTODO ("Implement")]
  275. protected void UnknownAttribute (object o, XmlAttribute attr)
  276. {
  277. throw new NotImplementedException ();
  278. }
  279. [MonoTODO ("Implement")]
  280. protected void UnknownElement (object o, XmlElement elem)
  281. {
  282. throw new NotImplementedException ();
  283. }
  284. [MonoTODO ("Implement")]
  285. protected void UnknownNode (object o)
  286. {
  287. throw new NotImplementedException ();
  288. }
  289. [MonoTODO ("Implement")]
  290. protected void UnreferencedObject (string id, object o)
  291. {
  292. throw new NotImplementedException ();
  293. }
  294. #endregion // Methods
  295. protected class CollectionFixup {
  296. #region Fields
  297. XmlSerializationCollectionFixupCallback callback;
  298. object collection;
  299. object collectionItems;
  300. #endregion // Fields
  301. #region Constructors
  302. [MonoTODO]
  303. public CollectionFixup (object collection, XmlSerializationCollectionFixupCallback callback, object collectionItems)
  304. {
  305. this.callback = callback;
  306. this.collection = collection;
  307. this.collectionItems = collectionItems;
  308. }
  309. #endregion // Constructors
  310. #region Properties
  311. public XmlSerializationCollectionFixupCallback Callback {
  312. get { return callback; }
  313. }
  314. public object Collection {
  315. get { return collection; }
  316. }
  317. public object CollectionItems {
  318. get { return collectionItems; }
  319. }
  320. #endregion // Properties
  321. }
  322. protected class Fixup {
  323. #region Fields
  324. object source;
  325. string[] ids;
  326. XmlSerializationFixupCallback callback;
  327. #endregion // Fields
  328. #region Constructors
  329. [MonoTODO]
  330. public Fixup (object o, XmlSerializationFixupCallback callback, int count)
  331. {
  332. this.callback = callback;
  333. }
  334. [MonoTODO]
  335. public Fixup (object o, XmlSerializationFixupCallback callback, string[] ids)
  336. {
  337. this.callback = callback;
  338. }
  339. #endregion // Constructors
  340. #region Properties
  341. public XmlSerializationFixupCallback Callback {
  342. get { return callback; }
  343. }
  344. public string[] Ids {
  345. get { return ids; }
  346. }
  347. public object Source {
  348. get { return source; }
  349. set { source = value; }
  350. }
  351. #endregion // Properties
  352. }
  353. }
  354. }