XmlDictionaryReader.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. //
  2. // XmlDictionaryReader.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // Copyright (C) 2005, 2007 Novell, Inc. http://www.novell.com
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. using System;
  29. using System.IO;
  30. using System.Reflection;
  31. using System.Text;
  32. using System.Xml;
  33. namespace System.Xml
  34. {
  35. public abstract partial class XmlDictionaryReader : XmlReader
  36. {
  37. protected XmlDictionaryReader ()
  38. {
  39. }
  40. XmlDictionaryReaderQuotas quotas;
  41. public virtual bool CanCanonicalize {
  42. get { return false; }
  43. }
  44. public virtual XmlDictionaryReaderQuotas Quotas {
  45. get {
  46. if (quotas == null)
  47. quotas = new XmlDictionaryReaderQuotas ();
  48. return quotas;
  49. }
  50. }
  51. public virtual void EndCanonicalization ()
  52. {
  53. throw new NotSupportedException ();
  54. }
  55. public virtual string GetAttribute (
  56. XmlDictionaryString localName,
  57. XmlDictionaryString namespaceUri)
  58. {
  59. if (localName == null)
  60. throw new ArgumentNullException ("localName");
  61. if (namespaceUri == null)
  62. throw new ArgumentNullException ("namespaceUri");
  63. return GetAttribute (localName.Value, namespaceUri.Value);
  64. }
  65. public virtual int IndexOfLocalName (
  66. string [] localNames, string namespaceUri)
  67. {
  68. if (localNames == null)
  69. throw new ArgumentNullException ("localNames");
  70. if (namespaceUri == null)
  71. throw new ArgumentNullException ("namespaceUri");
  72. if (NamespaceURI != namespaceUri)
  73. return -1;
  74. for (int i = 0; i < localNames.Length; i++)
  75. if (localNames [i] == LocalName)
  76. return i;
  77. return -1;
  78. }
  79. public virtual int IndexOfLocalName (
  80. XmlDictionaryString [] localNames,
  81. XmlDictionaryString namespaceUri)
  82. {
  83. if (localNames == null)
  84. throw new ArgumentNullException ("localNames");
  85. if (namespaceUri == null)
  86. throw new ArgumentNullException ("namespaceUri");
  87. if (NamespaceURI != namespaceUri.Value)
  88. return -1;
  89. XmlDictionaryString localName;
  90. if (!TryGetLocalNameAsDictionaryString (out localName))
  91. return -1;
  92. IXmlDictionary dict = localName.Dictionary;
  93. XmlDictionaryString iter;
  94. for (int i = 0; i < localNames.Length; i++)
  95. if (dict.TryLookup (localNames [i], out iter) && object.ReferenceEquals (iter, localName))
  96. return i;
  97. return -1;
  98. }
  99. public virtual bool IsArray (out Type type)
  100. {
  101. type = null;
  102. return false;
  103. }
  104. public virtual bool IsLocalName (string localName)
  105. {
  106. return LocalName == localName;
  107. }
  108. public virtual bool IsLocalName (XmlDictionaryString localName)
  109. {
  110. if (localName == null)
  111. throw new ArgumentNullException ("localName");
  112. return LocalName == localName.Value;
  113. }
  114. public virtual bool IsNamespaceUri (string namespaceUri)
  115. {
  116. return NamespaceURI == namespaceUri;
  117. }
  118. public virtual bool IsNamespaceUri (XmlDictionaryString namespaceUri)
  119. {
  120. if (namespaceUri == null)
  121. throw new ArgumentNullException ("namespaceUri");
  122. return NamespaceURI == namespaceUri.Value;
  123. }
  124. public virtual bool IsStartArray (out Type type)
  125. {
  126. type = null;
  127. return false;
  128. }
  129. public virtual bool IsStartElement (
  130. XmlDictionaryString localName,
  131. XmlDictionaryString namespaceUri)
  132. {
  133. if (localName == null)
  134. throw new ArgumentNullException ("localName");
  135. if (namespaceUri == null)
  136. throw new ArgumentNullException ("namespaceUri");
  137. return IsStartElement (localName.Value, namespaceUri.Value);
  138. }
  139. protected bool IsTextNode (XmlNodeType nodeType)
  140. {
  141. switch (nodeType) {
  142. case XmlNodeType.Attribute: // wow, it isn't indeed.
  143. case XmlNodeType.Text:
  144. case XmlNodeType.CDATA:
  145. case XmlNodeType.Whitespace:
  146. case XmlNodeType.SignificantWhitespace:
  147. return true;
  148. default:
  149. return false;
  150. }
  151. }
  152. XmlException XmlError (string message)
  153. {
  154. IXmlLineInfo li = this as IXmlLineInfo;
  155. if (li == null || !li.HasLineInfo ())
  156. return new XmlException (message);
  157. else
  158. return new XmlException (String.Format ("{0} in {1} , at ({2},{3})", message, BaseURI, li.LineNumber, li.LinePosition));
  159. }
  160. public virtual void MoveToStartElement ()
  161. {
  162. MoveToContent ();
  163. if (NodeType != XmlNodeType.Element)
  164. throw XmlError (String.Format ("Element node is expected, but got {0} node.", NodeType));
  165. }
  166. public virtual void MoveToStartElement (string name)
  167. {
  168. if (name == null)
  169. throw new ArgumentNullException ("name");
  170. MoveToStartElement ();
  171. if (Name != name)
  172. throw XmlError (String.Format ("Element node '{0}' is expected, but got '{1}' element.", name, Name));
  173. }
  174. public virtual void MoveToStartElement (
  175. string localName, string namespaceUri)
  176. {
  177. if (localName == null)
  178. throw new ArgumentNullException ("localName");
  179. if (namespaceUri == null)
  180. throw new ArgumentNullException ("namespaceUri");
  181. MoveToStartElement ();
  182. if (LocalName != localName || NamespaceURI != namespaceUri)
  183. throw XmlError (String.Format ("Element node '{0}' in namespace '{1}' is expected, but got '{2}' in namespace '{3}' element.", localName, namespaceUri, LocalName, NamespaceURI));
  184. }
  185. public virtual void MoveToStartElement (
  186. XmlDictionaryString localName,
  187. XmlDictionaryString namespaceUri)
  188. {
  189. if (localName == null)
  190. throw new ArgumentNullException ("localName");
  191. if (namespaceUri == null)
  192. throw new ArgumentNullException ("namespaceUri");
  193. MoveToStartElement (localName.Value, namespaceUri.Value);
  194. }
  195. public virtual void StartCanonicalization (
  196. Stream stream, bool includeComments,
  197. string [] inclusivePrefixes)
  198. {
  199. throw new NotSupportedException ();
  200. }
  201. public virtual bool TryGetArrayLength (out int count)
  202. {
  203. count = -1;
  204. return false;
  205. }
  206. public virtual bool TryGetBase64ContentLength (out int count)
  207. {
  208. count = -1;
  209. return false;
  210. }
  211. public virtual bool TryGetLocalNameAsDictionaryString (
  212. out XmlDictionaryString localName)
  213. {
  214. localName = null;
  215. return false;
  216. }
  217. public virtual bool TryGetNamespaceUriAsDictionaryString (
  218. out XmlDictionaryString namespaceUri)
  219. {
  220. namespaceUri = null;
  221. return false;
  222. }
  223. #region Content Reader Methods
  224. public override object ReadContentAs (Type type, IXmlNamespaceResolver nsResolver)
  225. {
  226. return base.ReadContentAs (type, nsResolver);
  227. }
  228. public virtual byte [] ReadContentAsBase64 ()
  229. {
  230. int len;
  231. if (!TryGetBase64ContentLength (out len))
  232. return Convert.FromBase64String (ReadContentAsString ());
  233. byte [] bytes = new byte [len];
  234. ReadContentAsBase64 (bytes, 0, len);
  235. return bytes;
  236. }
  237. MethodInfo xmlconv_from_bin_hex = typeof (XmlConvert).GetMethod ("FromBinHexString", BindingFlags.Static | BindingFlags.NonPublic, null, new Type [] {typeof (string)}, null);
  238. byte [] FromBinHexString (string s)
  239. {
  240. return (byte []) xmlconv_from_bin_hex.Invoke (null, new object [] {s});
  241. }
  242. public virtual byte [] ReadContentAsBinHex ()
  243. {
  244. int len;
  245. if (!TryGetArrayLength (out len))
  246. return FromBinHexString (ReadContentAsString ());
  247. return ReadContentAsBinHex (len);
  248. }
  249. protected byte [] ReadContentAsBinHex (int maxByteArrayContentLength)
  250. {
  251. byte [] bytes = new byte [maxByteArrayContentLength];
  252. ReadContentAsBinHex (bytes, 0, maxByteArrayContentLength);
  253. return bytes;
  254. }
  255. [MonoTODO]
  256. public virtual int ReadContentAsChars (char [] chars, int offset, int count)
  257. {
  258. throw new NotImplementedException ();
  259. }
  260. public override decimal ReadContentAsDecimal ()
  261. {
  262. return base.ReadContentAsDecimal ();
  263. }
  264. public override float ReadContentAsFloat ()
  265. {
  266. return base.ReadContentAsFloat ();
  267. }
  268. public virtual Guid ReadContentAsGuid ()
  269. {
  270. return XmlConvert.ToGuid (ReadContentAsString ());
  271. }
  272. public virtual void ReadContentAsQualifiedName (out string localName, out string namespaceUri)
  273. {
  274. XmlQualifiedName qname = (XmlQualifiedName) ReadContentAs (typeof (XmlQualifiedName), this as IXmlNamespaceResolver);
  275. localName = qname.Name;
  276. namespaceUri = qname.Namespace;
  277. }
  278. public override string ReadContentAsString ()
  279. {
  280. return ReadContentAsString (Quotas.MaxStringContentLength);
  281. }
  282. [MonoTODO]
  283. protected string ReadContentAsString (int maxStringContentLength)
  284. {
  285. return base.ReadContentAsString ();
  286. }
  287. [MonoTODO ("there is exactly no information on the web")]
  288. public virtual string ReadContentAsString (string [] strings, out int index)
  289. {
  290. throw new NotImplementedException ();
  291. }
  292. [MonoTODO ("there is exactly no information on the web")]
  293. public virtual string ReadContentAsString (XmlDictionaryString [] strings, out int index)
  294. {
  295. throw new NotImplementedException ();
  296. }
  297. public virtual TimeSpan ReadContentAsTimeSpan ()
  298. {
  299. return XmlConvert.ToTimeSpan (ReadContentAsString ());
  300. }
  301. public virtual UniqueId ReadContentAsUniqueId ()
  302. {
  303. return new UniqueId (ReadContentAsString ());
  304. }
  305. public virtual byte [] ReadElementContentAsBase64 ()
  306. {
  307. ReadStartElement ();
  308. byte [] ret = ReadContentAsBase64 ();
  309. ReadEndElement ();
  310. return ret;
  311. }
  312. public virtual byte [] ReadElementContentAsBinHex ()
  313. {
  314. ReadStartElement ();
  315. byte [] ret = ReadContentAsBinHex ();
  316. ReadEndElement ();
  317. return ret;
  318. }
  319. public virtual Guid ReadElementContentAsGuid ()
  320. {
  321. ReadStartElement ();
  322. Guid ret = ReadContentAsGuid ();
  323. ReadEndElement ();
  324. return ret;
  325. }
  326. public virtual TimeSpan ReadElementContentAsTimeSpan ()
  327. {
  328. ReadStartElement ();
  329. TimeSpan ret = ReadContentAsTimeSpan ();
  330. ReadEndElement ();
  331. return ret;
  332. }
  333. public virtual UniqueId ReadElementContentAsUniqueId ()
  334. {
  335. ReadStartElement ();
  336. UniqueId ret = ReadContentAsUniqueId ();
  337. ReadEndElement ();
  338. return ret;
  339. }
  340. public override string ReadElementContentAsString ()
  341. {
  342. if (IsEmptyElement) {
  343. Read ();
  344. return String.Empty;
  345. } else {
  346. ReadStartElement ();
  347. string s;
  348. if (NodeType == XmlNodeType.EndElement)
  349. s = String.Empty;
  350. else
  351. s = ReadContentAsString ();
  352. ReadEndElement ();
  353. return s;
  354. }
  355. }
  356. public virtual void ReadFullStartElement ()
  357. {
  358. if (!IsStartElement ())
  359. throw new XmlException ("Current node is not a start element");
  360. ReadStartElement ();
  361. }
  362. public virtual void ReadFullStartElement (string name)
  363. {
  364. if (!IsStartElement (name))
  365. throw new XmlException (String.Format ("Current node is not a start element '{0}'", name));
  366. ReadStartElement (name);
  367. }
  368. public virtual void ReadFullStartElement (string localName, string namespaceUri)
  369. {
  370. if (!IsStartElement (localName, namespaceUri))
  371. throw new XmlException (String.Format ("Current node is not a start element '{0}' in namesapce '{1}'", localName, namespaceUri));
  372. ReadStartElement (localName, namespaceUri);
  373. }
  374. public virtual void ReadFullStartElement (XmlDictionaryString localName, XmlDictionaryString namespaceUri)
  375. {
  376. if (!IsStartElement (localName, namespaceUri))
  377. throw new XmlException (String.Format ("Current node is not a start element '{0}' in namesapce '{1}'", localName, namespaceUri));
  378. ReadStartElement (localName.Value, namespaceUri.Value);
  379. }
  380. public virtual void ReadStartElement (XmlDictionaryString localName, XmlDictionaryString namespaceUri)
  381. {
  382. if (localName == null)
  383. throw new ArgumentNullException ("localName");
  384. if (namespaceUri == null)
  385. throw new ArgumentNullException ("namespaceUri");
  386. ReadStartElement (localName.Value, namespaceUri.Value);
  387. }
  388. public override string ReadString ()
  389. {
  390. return ReadString (Quotas.MaxStringContentLength);
  391. }
  392. [MonoTODO]
  393. protected string ReadString (int maxStringContentLength)
  394. {
  395. return base.ReadString ();
  396. }
  397. #if NET_2_1
  398. public virtual byte [] ReadValueAsBase64 (byte [] bytes, int start, int length)
  399. {
  400. throw new NotSupportedException (); // as it is documented ...
  401. }
  402. #endif
  403. public virtual bool TryGetValueAsDictionaryString (out XmlDictionaryString value)
  404. {
  405. throw new NotSupportedException (); // as documented
  406. }
  407. #endregion
  408. #region Factory Methods
  409. public static XmlDictionaryReader CreateBinaryReader (
  410. byte [] buffer, XmlDictionaryReaderQuotas quotas)
  411. {
  412. return CreateBinaryReader (buffer, 0, buffer.Length, quotas);
  413. }
  414. public static XmlDictionaryReader CreateBinaryReader (
  415. byte [] buffer, int offset, int count,
  416. XmlDictionaryReaderQuotas quotas)
  417. {
  418. return CreateBinaryReader (buffer, offset, count, new XmlDictionary (), quotas);
  419. }
  420. public static XmlDictionaryReader CreateBinaryReader (
  421. byte [] buffer, int offset, int count,
  422. IXmlDictionary dictionary,
  423. XmlDictionaryReaderQuotas quotas)
  424. {
  425. return CreateBinaryReader (buffer, offset, count,
  426. dictionary, quotas,
  427. new XmlBinaryReaderSession (), null);
  428. }
  429. public static XmlDictionaryReader CreateBinaryReader (
  430. byte [] buffer, int offset, int count,
  431. IXmlDictionary dictionary,
  432. XmlDictionaryReaderQuotas quotas,
  433. XmlBinaryReaderSession session)
  434. {
  435. return CreateBinaryReader (buffer, offset, count,
  436. dictionary, quotas,
  437. session, null);
  438. }
  439. public static XmlDictionaryReader CreateBinaryReader (
  440. byte [] buffer, int offset, int count,
  441. IXmlDictionary dictionary,
  442. XmlDictionaryReaderQuotas quotas,
  443. XmlBinaryReaderSession session,
  444. OnXmlDictionaryReaderClose onClose)
  445. {
  446. return new XmlBinaryDictionaryReader (buffer,
  447. offset, count,
  448. dictionary, quotas, session, onClose);
  449. }
  450. public static XmlDictionaryReader CreateBinaryReader (
  451. Stream stream, XmlDictionaryReaderQuotas quotas)
  452. {
  453. return CreateBinaryReader (stream, new XmlDictionary (), quotas);
  454. }
  455. public static XmlDictionaryReader CreateBinaryReader (
  456. Stream stream, IXmlDictionary dictionary,
  457. XmlDictionaryReaderQuotas quotas)
  458. {
  459. return CreateBinaryReader (stream, dictionary, quotas,
  460. new XmlBinaryReaderSession (), null);
  461. }
  462. public static XmlDictionaryReader CreateBinaryReader (
  463. Stream stream, IXmlDictionary dictionary,
  464. XmlDictionaryReaderQuotas quotas,
  465. XmlBinaryReaderSession session)
  466. {
  467. return CreateBinaryReader (stream, dictionary, quotas,
  468. session, null);
  469. }
  470. public static XmlDictionaryReader CreateBinaryReader (
  471. Stream stream, IXmlDictionary dictionary,
  472. XmlDictionaryReaderQuotas quotas,
  473. XmlBinaryReaderSession session,
  474. OnXmlDictionaryReaderClose onClose)
  475. {
  476. return new XmlBinaryDictionaryReader (stream,
  477. dictionary, quotas, session, onClose);
  478. }
  479. public static XmlDictionaryReader CreateDictionaryReader (
  480. XmlReader reader)
  481. {
  482. return new XmlSimpleDictionaryReader (reader);
  483. }
  484. #if !NET_2_1
  485. public static XmlDictionaryReader CreateMtomReader (
  486. Stream stream, Encoding encoding,
  487. XmlDictionaryReaderQuotas quotas)
  488. {
  489. return new XmlMtomDictionaryReader (stream, encoding, quotas);
  490. }
  491. public static XmlDictionaryReader CreateMtomReader (
  492. Stream stream, Encoding [] encodings,
  493. XmlDictionaryReaderQuotas quotas)
  494. {
  495. return CreateMtomReader (stream, encodings, null, quotas);
  496. }
  497. public static XmlDictionaryReader CreateMtomReader (
  498. Stream stream, Encoding [] encodings, string contentType,
  499. XmlDictionaryReaderQuotas quotas)
  500. {
  501. return CreateMtomReader (stream, encodings, contentType, quotas, int.MaxValue, null);
  502. }
  503. public static XmlDictionaryReader CreateMtomReader (
  504. Stream stream, Encoding [] encodings, string contentType,
  505. XmlDictionaryReaderQuotas quotas,
  506. int maxBufferSize,
  507. OnXmlDictionaryReaderClose onClose)
  508. {
  509. return new XmlMtomDictionaryReader (stream, encodings, contentType, quotas, maxBufferSize, onClose);
  510. }
  511. public static XmlDictionaryReader CreateMtomReader (
  512. byte [] buffer, int offset, int count,
  513. Encoding encoding, XmlDictionaryReaderQuotas quotas)
  514. {
  515. return CreateMtomReader (new MemoryStream (buffer, offset, count), encoding, quotas);
  516. }
  517. public static XmlDictionaryReader CreateMtomReader (
  518. byte [] buffer, int offset, int count,
  519. Encoding [] encodings, XmlDictionaryReaderQuotas quotas)
  520. {
  521. return CreateMtomReader (new MemoryStream (buffer, offset, count), encodings, quotas);
  522. }
  523. public static XmlDictionaryReader CreateMtomReader (
  524. byte [] buffer, int offset, int count,
  525. Encoding [] encodings, string contentType,
  526. XmlDictionaryReaderQuotas quotas)
  527. {
  528. return CreateMtomReader (new MemoryStream (buffer, offset, count), encodings, contentType, quotas);
  529. }
  530. public static XmlDictionaryReader CreateMtomReader (
  531. byte [] buffer, int offset, int count,
  532. Encoding [] encodings, string contentType,
  533. XmlDictionaryReaderQuotas quotas,
  534. int maxBufferSize,
  535. OnXmlDictionaryReaderClose onClose)
  536. {
  537. return CreateMtomReader (new MemoryStream (buffer, offset, count), encodings, contentType, quotas, maxBufferSize, onClose);
  538. }
  539. #endif
  540. public static XmlDictionaryReader CreateTextReader (byte [] buffer, XmlDictionaryReaderQuotas quotas)
  541. {
  542. return CreateTextReader (buffer, 0, buffer.Length, quotas);
  543. }
  544. public static XmlDictionaryReader CreateTextReader (
  545. byte [] buffer, int offset, int count,
  546. XmlDictionaryReaderQuotas quotas)
  547. {
  548. return CreateTextReader (buffer, offset, count,
  549. Encoding.UTF8, quotas, null);
  550. }
  551. public static XmlDictionaryReader CreateTextReader (
  552. byte [] buffer, int offset, int count,
  553. Encoding encoding,
  554. XmlDictionaryReaderQuotas quotas,
  555. OnXmlDictionaryReaderClose onClose)
  556. {
  557. return CreateTextReader (new MemoryStream (buffer, offset, count), encoding, quotas, onClose);
  558. }
  559. public static XmlDictionaryReader CreateTextReader (
  560. Stream stream, XmlDictionaryReaderQuotas quotas)
  561. {
  562. return CreateTextReader (stream, Encoding.UTF8, quotas, null);
  563. }
  564. public static XmlDictionaryReader CreateTextReader (
  565. Stream stream, Encoding encoding,
  566. XmlDictionaryReaderQuotas quotas,
  567. OnXmlDictionaryReaderClose onClose)
  568. {
  569. XmlReaderSettings s = new XmlReaderSettings ();
  570. XmlNameTable nt = new NameTable ();
  571. XmlParserContext c = new XmlParserContext (nt, new XmlNamespaceManager (nt), String.Empty, XmlSpace.None, encoding);
  572. XmlDictionaryReader res = new XmlSimpleDictionaryReader (XmlReader.Create (stream, s, c), null, onClose);
  573. res.quotas = quotas;
  574. return res;
  575. }
  576. #endregion
  577. }
  578. }