XmlDictionaryReader.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  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. public virtual int ReadValueAsBase64 (byte [] bytes, int start, int length)
  398. {
  399. throw new NotSupportedException (); // as it is documented ...
  400. }
  401. public virtual bool TryGetValueAsDictionaryString (out XmlDictionaryString value)
  402. {
  403. throw new NotSupportedException (); // as documented
  404. }
  405. #endregion
  406. #region Factory Methods
  407. public static XmlDictionaryReader CreateBinaryReader (
  408. byte [] buffer, XmlDictionaryReaderQuotas quotas)
  409. {
  410. return CreateBinaryReader (buffer, 0, buffer.Length, quotas);
  411. }
  412. public static XmlDictionaryReader CreateBinaryReader (
  413. byte [] buffer, int offset, int count,
  414. XmlDictionaryReaderQuotas quotas)
  415. {
  416. return CreateBinaryReader (buffer, offset, count, new XmlDictionary (), quotas);
  417. }
  418. public static XmlDictionaryReader CreateBinaryReader (
  419. byte [] buffer, int offset, int count,
  420. IXmlDictionary dictionary,
  421. XmlDictionaryReaderQuotas quotas)
  422. {
  423. return CreateBinaryReader (buffer, offset, count,
  424. dictionary, quotas,
  425. new XmlBinaryReaderSession (), null);
  426. }
  427. public static XmlDictionaryReader CreateBinaryReader (
  428. byte [] buffer, int offset, int count,
  429. IXmlDictionary dictionary,
  430. XmlDictionaryReaderQuotas quotas,
  431. XmlBinaryReaderSession session)
  432. {
  433. return CreateBinaryReader (buffer, offset, count,
  434. dictionary, quotas,
  435. session, null);
  436. }
  437. public static XmlDictionaryReader CreateBinaryReader (
  438. byte [] buffer, int offset, int count,
  439. IXmlDictionary dictionary,
  440. XmlDictionaryReaderQuotas quotas,
  441. XmlBinaryReaderSession session,
  442. OnXmlDictionaryReaderClose onClose)
  443. {
  444. return new XmlBinaryDictionaryReader (buffer,
  445. offset, count,
  446. dictionary, quotas, session, onClose);
  447. }
  448. public static XmlDictionaryReader CreateBinaryReader (
  449. Stream stream, XmlDictionaryReaderQuotas quotas)
  450. {
  451. return CreateBinaryReader (stream, new XmlDictionary (), quotas);
  452. }
  453. public static XmlDictionaryReader CreateBinaryReader (
  454. Stream stream, IXmlDictionary dictionary,
  455. XmlDictionaryReaderQuotas quotas)
  456. {
  457. return CreateBinaryReader (stream, dictionary, quotas,
  458. new XmlBinaryReaderSession (), null);
  459. }
  460. public static XmlDictionaryReader CreateBinaryReader (
  461. Stream stream, IXmlDictionary dictionary,
  462. XmlDictionaryReaderQuotas quotas,
  463. XmlBinaryReaderSession session)
  464. {
  465. return CreateBinaryReader (stream, dictionary, quotas,
  466. session, null);
  467. }
  468. public static XmlDictionaryReader CreateBinaryReader (
  469. Stream stream, IXmlDictionary dictionary,
  470. XmlDictionaryReaderQuotas quotas,
  471. XmlBinaryReaderSession session,
  472. OnXmlDictionaryReaderClose onClose)
  473. {
  474. return new XmlBinaryDictionaryReader (stream,
  475. dictionary, quotas, session, onClose);
  476. }
  477. public static XmlDictionaryReader CreateDictionaryReader (
  478. XmlReader reader)
  479. {
  480. return new XmlSimpleDictionaryReader (reader);
  481. }
  482. #if !NET_2_1
  483. public static XmlDictionaryReader CreateMtomReader (
  484. Stream stream, Encoding encoding,
  485. XmlDictionaryReaderQuotas quotas)
  486. {
  487. return new XmlMtomDictionaryReader (stream, encoding, quotas);
  488. }
  489. public static XmlDictionaryReader CreateMtomReader (
  490. Stream stream, Encoding [] encodings,
  491. XmlDictionaryReaderQuotas quotas)
  492. {
  493. return CreateMtomReader (stream, encodings, null, quotas);
  494. }
  495. public static XmlDictionaryReader CreateMtomReader (
  496. Stream stream, Encoding [] encodings, string contentType,
  497. XmlDictionaryReaderQuotas quotas)
  498. {
  499. return CreateMtomReader (stream, encodings, contentType, quotas, int.MaxValue, null);
  500. }
  501. public static XmlDictionaryReader CreateMtomReader (
  502. Stream stream, Encoding [] encodings, string contentType,
  503. XmlDictionaryReaderQuotas quotas,
  504. int maxBufferSize,
  505. OnXmlDictionaryReaderClose onClose)
  506. {
  507. return new XmlMtomDictionaryReader (stream, encodings, contentType, quotas, maxBufferSize, onClose);
  508. }
  509. public static XmlDictionaryReader CreateMtomReader (
  510. byte [] buffer, int offset, int count,
  511. Encoding encoding, XmlDictionaryReaderQuotas quotas)
  512. {
  513. return CreateMtomReader (new MemoryStream (buffer, offset, count), encoding, quotas);
  514. }
  515. public static XmlDictionaryReader CreateMtomReader (
  516. byte [] buffer, int offset, int count,
  517. Encoding [] encodings, XmlDictionaryReaderQuotas quotas)
  518. {
  519. return CreateMtomReader (new MemoryStream (buffer, offset, count), encodings, quotas);
  520. }
  521. public static XmlDictionaryReader CreateMtomReader (
  522. byte [] buffer, int offset, int count,
  523. Encoding [] encodings, string contentType,
  524. XmlDictionaryReaderQuotas quotas)
  525. {
  526. return CreateMtomReader (new MemoryStream (buffer, offset, count), encodings, contentType, quotas);
  527. }
  528. public static XmlDictionaryReader CreateMtomReader (
  529. byte [] buffer, int offset, int count,
  530. Encoding [] encodings, string contentType,
  531. XmlDictionaryReaderQuotas quotas,
  532. int maxBufferSize,
  533. OnXmlDictionaryReaderClose onClose)
  534. {
  535. return CreateMtomReader (new MemoryStream (buffer, offset, count), encodings, contentType, quotas, maxBufferSize, onClose);
  536. }
  537. #endif
  538. public static XmlDictionaryReader CreateTextReader (byte [] buffer, XmlDictionaryReaderQuotas quotas)
  539. {
  540. return CreateTextReader (buffer, 0, buffer.Length, quotas);
  541. }
  542. public static XmlDictionaryReader CreateTextReader (
  543. byte [] buffer, int offset, int count,
  544. XmlDictionaryReaderQuotas quotas)
  545. {
  546. return CreateTextReader (buffer, offset, count,
  547. Encoding.UTF8, quotas, null);
  548. }
  549. public static XmlDictionaryReader CreateTextReader (
  550. byte [] buffer, int offset, int count,
  551. Encoding encoding,
  552. XmlDictionaryReaderQuotas quotas,
  553. OnXmlDictionaryReaderClose onClose)
  554. {
  555. return CreateTextReader (new MemoryStream (buffer, offset, count), encoding, quotas, onClose);
  556. }
  557. public static XmlDictionaryReader CreateTextReader (
  558. Stream stream, XmlDictionaryReaderQuotas quotas)
  559. {
  560. return CreateTextReader (stream, Encoding.UTF8, quotas, null);
  561. }
  562. public static XmlDictionaryReader CreateTextReader (
  563. Stream stream, Encoding encoding,
  564. XmlDictionaryReaderQuotas quotas,
  565. OnXmlDictionaryReaderClose onClose)
  566. {
  567. XmlReaderSettings s = new XmlReaderSettings ();
  568. XmlNameTable nt = new NameTable ();
  569. XmlParserContext c = new XmlParserContext (nt, new XmlNamespaceManager (nt), String.Empty, XmlSpace.None, encoding);
  570. XmlDictionaryReader res = new XmlSimpleDictionaryReader (XmlReader.Create (stream, s, c), null, onClose);
  571. res.quotas = quotas;
  572. return res;
  573. }
  574. #endregion
  575. }
  576. }