QuerySafeNavigator.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939
  1. //------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------
  4. namespace System.ServiceModel.Dispatcher
  5. {
  6. using System.Runtime;
  7. using System.Xml;
  8. using System.Xml.XPath;
  9. #if NO
  10. //
  11. // A message is just one more source of Xml data. To filter a message, we create a navigator over it that
  12. // surfaces its contained Xml to the filter engine.
  13. // In M5.1, we navigate messages by first writing them into a message document. This turns the message into an
  14. // Xml DOM. we then get a navigator from the DOM.
  15. // In M5.2, we'll navigate messages without requiring this step.
  16. //
  17. internal class MessageNavigator : GenericSeekableNavigator
  18. {
  19. StringBuilder builder;
  20. int headerCollectionVersion;
  21. bool loaded;
  22. bool navigatesBody;
  23. internal MessageNavigator(MessageNavigator nav)
  24. : base(nav)
  25. {
  26. this.headerCollectionVersion = nav.headerCollectionVersion;
  27. this.loaded = nav.loaded;
  28. this.navigatesBody = nav.navigatesBody;
  29. }
  30. internal MessageNavigator(Message message, bool navigateBody)
  31. : base()
  32. {
  33. this.navigatesBody = navigateBody;
  34. this.Load(message, this.navigatesBody);
  35. }
  36. internal bool IsLoaded
  37. {
  38. get
  39. {
  40. return this.loaded;
  41. }
  42. }
  43. internal bool NavigatesBody
  44. {
  45. get
  46. {
  47. return this.navigatesBody;
  48. }
  49. }
  50. internal override void Clear()
  51. {
  52. base.Clear();
  53. this.loaded = false;
  54. this.navigatesBody = false;
  55. }
  56. public override XPathNavigator Clone()
  57. {
  58. return new MessageNavigator(this);
  59. }
  60. internal MessageNavigator Ensure(Message message, bool navigateBody)
  61. {
  62. // Rebuild the navigator if:
  63. // If this navigator does not navigate on bodies and now we need to (or vice versa)
  64. // Or the header collection changed under us
  65. if (this.navigatesBody != navigateBody || message.Headers.CollectionVersion != this.headerCollectionVersion)
  66. {
  67. this.Load(message, navigateBody);
  68. }
  69. else
  70. {
  71. this.MoveToRoot();
  72. }
  73. return this;
  74. }
  75. // To load a message into a message document, we write the message into a buffer and then let XPathDocument
  76. // load that buffer
  77. internal void Load(Message message, bool navigatesBody)
  78. {
  79. if (null == this.builder)
  80. {
  81. this.builder = new StringBuilder(1024);
  82. }
  83. StringWriter stringWriter = new StringWriter(this.builder);
  84. XmlWriter writer = new XmlTextWriter(stringWriter);
  85. message.WriteMessage(writer, navigatesBody);
  86. writer.Close();
  87. StringReader reader = new StringReader(this.builder.ToString());
  88. XPathDocument messageDoc = new XPathDocument(reader);
  89. reader.Close();
  90. this.builder.Length = 0;
  91. this.Init(messageDoc.CreateNavigator());
  92. this.loaded = true;
  93. this.navigatesBody = navigatesBody;
  94. this.headerCollectionVersion = message.Headers.CollectionVersion;
  95. }
  96. }
  97. #endif
  98. // To prevent XPaths from running forever etc, users can specify limits on:
  99. // the # of nodes a filter or filter table should inspect
  100. //
  101. // This file contains navigators that impose these limits
  102. internal interface INodeCounter
  103. {
  104. int CounterMarker { get; set; }
  105. int MaxCounter { set; }
  106. int ElapsedCount(int marker);
  107. void Increase();
  108. void IncreaseBy(int count);
  109. }
  110. internal class DummyNodeCounter : INodeCounter
  111. {
  112. internal static DummyNodeCounter Dummy = new DummyNodeCounter();
  113. public int CounterMarker
  114. {
  115. get { return 0; }
  116. set { }
  117. }
  118. public int MaxCounter
  119. {
  120. set { }
  121. }
  122. public int ElapsedCount(int marker) { return 0; }
  123. public void Increase() { }
  124. public void IncreaseBy(int count) { }
  125. }
  126. /// <summary>
  127. /// Seekable navigators that wrap other navigators and doesn't exceed node counting limits
  128. /// </summary>
  129. internal class SafeSeekableNavigator : SeekableXPathNavigator, INodeCounter
  130. {
  131. SeekableXPathNavigator navigator;
  132. SafeSeekableNavigator counter;
  133. int nodeCount;
  134. int nodeCountMax;
  135. internal SafeSeekableNavigator(SafeSeekableNavigator nav)
  136. {
  137. this.navigator = (SeekableXPathNavigator)nav.navigator.Clone();
  138. this.counter = nav.counter;
  139. }
  140. internal SafeSeekableNavigator(SeekableXPathNavigator navigator, int nodeCountMax)
  141. {
  142. this.navigator = navigator;
  143. this.counter = this;
  144. this.nodeCount = nodeCountMax;
  145. this.nodeCountMax = nodeCountMax;
  146. }
  147. public override string BaseURI
  148. {
  149. get
  150. {
  151. return this.navigator.BaseURI;
  152. }
  153. }
  154. public int CounterMarker
  155. {
  156. get
  157. {
  158. return this.counter.nodeCount;
  159. }
  160. set
  161. {
  162. this.counter.nodeCount = value;
  163. }
  164. }
  165. public int MaxCounter
  166. {
  167. set
  168. {
  169. this.counter.nodeCountMax = value;
  170. }
  171. }
  172. /// <summary>
  173. /// Setting the current position moves this navigator to the location specified by the given position
  174. /// </summary>
  175. public override long CurrentPosition
  176. {
  177. get
  178. {
  179. return this.navigator.CurrentPosition;
  180. }
  181. set
  182. {
  183. this.navigator.CurrentPosition = value;
  184. }
  185. }
  186. public override bool HasAttributes
  187. {
  188. get
  189. {
  190. return this.navigator.HasAttributes;
  191. }
  192. }
  193. public override bool HasChildren
  194. {
  195. get
  196. {
  197. return this.navigator.HasChildren;
  198. }
  199. }
  200. public override bool IsEmptyElement
  201. {
  202. get
  203. {
  204. return this.navigator.IsEmptyElement;
  205. }
  206. }
  207. public override string LocalName
  208. {
  209. get
  210. {
  211. return this.navigator.LocalName;
  212. }
  213. }
  214. public override string Name
  215. {
  216. get
  217. {
  218. return this.navigator.Name;
  219. }
  220. }
  221. public override string NamespaceURI
  222. {
  223. get
  224. {
  225. return this.navigator.NamespaceURI;
  226. }
  227. }
  228. public override XmlNameTable NameTable
  229. {
  230. get
  231. {
  232. return this.navigator.NameTable;
  233. }
  234. }
  235. public override XPathNodeType NodeType
  236. {
  237. get
  238. {
  239. return this.navigator.NodeType;
  240. }
  241. }
  242. public override string Prefix
  243. {
  244. get
  245. {
  246. return this.navigator.Prefix;
  247. }
  248. }
  249. public override string Value
  250. {
  251. get
  252. {
  253. return this.navigator.Value;
  254. }
  255. }
  256. public override string XmlLang
  257. {
  258. get
  259. {
  260. return this.navigator.XmlLang;
  261. }
  262. }
  263. public override XPathNavigator Clone()
  264. {
  265. return new SafeSeekableNavigator(this);
  266. }
  267. #if NO
  268. internal SafeNavigator CreateSafeXPathNavigator()
  269. {
  270. return new SafeNavigator(this, this.navigator);
  271. }
  272. #endif
  273. public override XmlNodeOrder ComparePosition(XPathNavigator navigator)
  274. {
  275. if (navigator == null)
  276. {
  277. return XmlNodeOrder.Unknown;
  278. }
  279. SafeSeekableNavigator nav = navigator as SafeSeekableNavigator;
  280. if (nav != null)
  281. {
  282. return this.navigator.ComparePosition(nav.navigator);
  283. }
  284. return XmlNodeOrder.Unknown;
  285. }
  286. public override XmlNodeOrder ComparePosition(long x, long y)
  287. {
  288. return this.navigator.ComparePosition(x, y);
  289. }
  290. public int ElapsedCount(int marker)
  291. {
  292. return marker - this.counter.nodeCount;
  293. }
  294. public override string GetLocalName(long nodePosition)
  295. {
  296. return this.navigator.GetLocalName(nodePosition);
  297. }
  298. public override string GetName(long nodePosition)
  299. {
  300. return this.navigator.GetName(nodePosition);
  301. }
  302. public override string GetNamespace(long nodePosition)
  303. {
  304. return this.navigator.GetNamespace(nodePosition);
  305. }
  306. public override XPathNodeType GetNodeType(long nodePosition)
  307. {
  308. return this.navigator.GetNodeType(nodePosition);
  309. }
  310. public override string GetValue(long nodePosition)
  311. {
  312. return this.navigator.GetValue(nodePosition);
  313. }
  314. public override string GetNamespace(string name)
  315. {
  316. this.IncrementNodeCount();
  317. return this.navigator.GetNamespace(name);
  318. }
  319. public override string GetAttribute(string localName, string namespaceURI)
  320. {
  321. this.IncrementNodeCount();
  322. return this.navigator.GetAttribute(localName, namespaceURI);
  323. }
  324. public void Increase()
  325. {
  326. this.IncrementNodeCount();
  327. }
  328. public void IncreaseBy(int count)
  329. {
  330. this.counter.nodeCount -= (count - 1);
  331. Increase();
  332. }
  333. internal void IncrementNodeCount()
  334. {
  335. if (this.counter.nodeCount > 0)
  336. {
  337. this.counter.nodeCount--;
  338. }
  339. else
  340. {
  341. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XPathNavigatorException(SR.GetString(SR.FilterNodeQuotaExceeded, this.counter.nodeCountMax)));
  342. }
  343. }
  344. #if NO
  345. internal virtual void Init(SeekableXPathNavigator navigator, int nodeCountMax)
  346. {
  347. this.navigator = navigator;
  348. this.nodeCount = nodeCountMax;
  349. this.counter = this;
  350. }
  351. #endif
  352. public override bool IsDescendant(XPathNavigator navigator)
  353. {
  354. if (navigator == null)
  355. {
  356. return false;
  357. }
  358. SafeSeekableNavigator nav = navigator as SafeSeekableNavigator;
  359. if (nav != null)
  360. {
  361. return this.navigator.IsDescendant(nav.navigator);
  362. }
  363. return false;
  364. }
  365. public override bool IsSamePosition(XPathNavigator other)
  366. {
  367. if (other == null)
  368. {
  369. return false;
  370. }
  371. SafeSeekableNavigator nav = other as SafeSeekableNavigator;
  372. if (nav != null)
  373. {
  374. return this.navigator.IsSamePosition(nav.navigator);
  375. }
  376. return false;
  377. }
  378. public override void MoveToRoot()
  379. {
  380. this.IncrementNodeCount();
  381. this.navigator.MoveToRoot();
  382. }
  383. public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope)
  384. {
  385. this.IncrementNodeCount();
  386. return this.navigator.MoveToNextNamespace(namespaceScope);
  387. }
  388. public override bool MoveToNextAttribute()
  389. {
  390. this.IncrementNodeCount();
  391. return this.navigator.MoveToNextAttribute();
  392. }
  393. public override bool MoveToPrevious()
  394. {
  395. this.IncrementNodeCount();
  396. return this.navigator.MoveToPrevious();
  397. }
  398. public override bool MoveToFirstAttribute()
  399. {
  400. this.IncrementNodeCount();
  401. return this.navigator.MoveToFirstAttribute();
  402. }
  403. public override bool MoveToNamespace(string name)
  404. {
  405. this.IncrementNodeCount();
  406. return this.navigator.MoveToNamespace(name);
  407. }
  408. public override bool MoveToParent()
  409. {
  410. this.IncrementNodeCount();
  411. return this.navigator.MoveToParent();
  412. }
  413. public override bool MoveTo(XPathNavigator other)
  414. {
  415. if (other == null)
  416. {
  417. return false;
  418. }
  419. this.IncrementNodeCount();
  420. SafeSeekableNavigator nav = other as SafeSeekableNavigator;
  421. if (nav != null)
  422. {
  423. return this.navigator.MoveTo(nav.navigator);
  424. }
  425. return false;
  426. }
  427. public override bool MoveToId(string id)
  428. {
  429. this.IncrementNodeCount();
  430. return this.navigator.MoveToId(id);
  431. }
  432. public override bool MoveToFirstChild()
  433. {
  434. this.IncrementNodeCount();
  435. return this.navigator.MoveToFirstChild();
  436. }
  437. public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope)
  438. {
  439. this.IncrementNodeCount();
  440. return this.navigator.MoveToFirstNamespace(namespaceScope);
  441. }
  442. public override bool MoveToAttribute(string localName, string namespaceURI)
  443. {
  444. this.IncrementNodeCount();
  445. return this.navigator.MoveToAttribute(localName, namespaceURI);
  446. }
  447. public override bool MoveToNext()
  448. {
  449. this.IncrementNodeCount();
  450. return this.navigator.MoveToNext();
  451. }
  452. public override bool MoveToFirst()
  453. {
  454. this.IncrementNodeCount();
  455. return this.navigator.MoveToFirst();
  456. }
  457. }
  458. /// <summary>
  459. /// The filter engine works with seekable navigators. This class takes a generic XPathNavigator implementation
  460. /// and transforms it into a seekable navigator. Seekable navigators associate a 'position' to every node in a DOM.
  461. ///
  462. /// This class maintains a (position, navigator) map. Cloning navigators is unavoidable - XPathNavigator offers
  463. /// no other way to snapshot its current position. However, caching allows memory allocations to be avoided - but
  464. /// only once the navigator is warmed up.
  465. /// </summary>
  466. internal class GenericSeekableNavigator : SeekableXPathNavigator
  467. {
  468. QueryBuffer<XPathNavigator> nodes;
  469. long currentPosition;
  470. XPathNavigator navigator;
  471. GenericSeekableNavigator dom;
  472. #if NO
  473. internal GenericSeekableNavigator()
  474. {
  475. this.nodes = new QueryBuffer<XPathNavigator>(4);
  476. this.currentPosition = -1;
  477. }
  478. #endif
  479. internal GenericSeekableNavigator(XPathNavigator navigator)
  480. {
  481. this.navigator = navigator;
  482. this.nodes = new QueryBuffer<XPathNavigator>(4);
  483. this.currentPosition = -1;
  484. this.dom = this;
  485. }
  486. internal GenericSeekableNavigator(GenericSeekableNavigator navigator)
  487. {
  488. this.navigator = navigator.navigator.Clone();
  489. this.nodes = default(QueryBuffer<XPathNavigator>);
  490. this.currentPosition = navigator.currentPosition;
  491. this.dom = navigator.dom;
  492. }
  493. public override string BaseURI
  494. {
  495. get
  496. {
  497. return this.navigator.BaseURI;
  498. }
  499. }
  500. public override bool HasAttributes
  501. {
  502. get
  503. {
  504. return this.navigator.HasAttributes;
  505. }
  506. }
  507. public override bool HasChildren
  508. {
  509. get
  510. {
  511. return this.navigator.HasChildren;
  512. }
  513. }
  514. #if NO
  515. internal XPathNavigator InternalNavigator
  516. {
  517. get
  518. {
  519. return this.navigator;
  520. }
  521. }
  522. #endif
  523. public override bool IsEmptyElement
  524. {
  525. get
  526. {
  527. return this.navigator.IsEmptyElement;
  528. }
  529. }
  530. public override string LocalName
  531. {
  532. get
  533. {
  534. return this.navigator.LocalName;
  535. }
  536. }
  537. public override string Name
  538. {
  539. get
  540. {
  541. return this.navigator.Name;
  542. }
  543. }
  544. public override string NamespaceURI
  545. {
  546. get
  547. {
  548. return this.navigator.NamespaceURI;
  549. }
  550. }
  551. public override XmlNameTable NameTable
  552. {
  553. get
  554. {
  555. return this.navigator.NameTable;
  556. }
  557. }
  558. public override XPathNodeType NodeType
  559. {
  560. get
  561. {
  562. return this.navigator.NodeType;
  563. }
  564. }
  565. public override string Prefix
  566. {
  567. get
  568. {
  569. return this.navigator.Prefix;
  570. }
  571. }
  572. public override string Value
  573. {
  574. get
  575. {
  576. return this.navigator.Value;
  577. }
  578. }
  579. public override string XmlLang
  580. {
  581. get
  582. {
  583. return this.navigator.XmlLang;
  584. }
  585. }
  586. /// <summary>
  587. /// Setting the current position moves this navigator to the location specified by the given position
  588. /// </summary>
  589. public override long CurrentPosition
  590. {
  591. get
  592. {
  593. if (-1 == this.currentPosition)
  594. {
  595. this.SnapshotNavigator();
  596. }
  597. return this.currentPosition;
  598. }
  599. set
  600. {
  601. this.navigator.MoveTo(this[value]);
  602. this.currentPosition = value;
  603. }
  604. }
  605. /// <summary>
  606. /// Return the XPathNavigator that has the given position
  607. /// </summary>
  608. internal XPathNavigator this[long nodePosition]
  609. {
  610. get
  611. {
  612. int pos = (int)nodePosition;
  613. Fx.Assert(this.dom.nodes.IsValidIndex(pos) && null != this.dom.nodes[pos], "");
  614. return this.dom.nodes[pos];
  615. }
  616. }
  617. #if NO
  618. internal virtual void Clear()
  619. {
  620. this.navigator = null;
  621. this.currentPosition = -1;
  622. }
  623. #endif
  624. public override XPathNavigator Clone()
  625. {
  626. return new GenericSeekableNavigator(this);
  627. }
  628. public override XmlNodeOrder ComparePosition(XPathNavigator navigator)
  629. {
  630. if (navigator == null)
  631. {
  632. return XmlNodeOrder.Unknown;
  633. }
  634. GenericSeekableNavigator nav = navigator as GenericSeekableNavigator;
  635. if (nav != null)
  636. {
  637. return this.navigator.ComparePosition(nav.navigator);
  638. }
  639. return XmlNodeOrder.Unknown;
  640. }
  641. public override XmlNodeOrder ComparePosition(long x, long y)
  642. {
  643. XPathNavigator nodeX = this[x];
  644. XPathNavigator nodeY = this[y];
  645. return nodeX.ComparePosition(nodeY);
  646. }
  647. public override string GetLocalName(long nodePosition)
  648. {
  649. return this[nodePosition].LocalName;
  650. }
  651. public override string GetName(long nodePosition)
  652. {
  653. return this[nodePosition].Name;
  654. }
  655. public override string GetNamespace(long nodePosition)
  656. {
  657. return this[nodePosition].NamespaceURI;
  658. }
  659. public override XPathNodeType GetNodeType(long nodePosition)
  660. {
  661. return this[nodePosition].NodeType;
  662. }
  663. public override string GetValue(long nodePosition)
  664. {
  665. return this[nodePosition].Value;
  666. }
  667. public override string GetNamespace(string name)
  668. {
  669. return this.navigator.GetNamespace(name);
  670. }
  671. public override string GetAttribute(string localName, string namespaceURI)
  672. {
  673. return this.navigator.GetAttribute(localName, namespaceURI);
  674. }
  675. #if NO
  676. internal void Init(XPathNavigator navigator)
  677. {
  678. Fx.Assert(null != navigator, "");
  679. this.navigator = navigator;
  680. this.currentPosition = -1;
  681. }
  682. #endif
  683. public override bool IsDescendant(XPathNavigator navigator)
  684. {
  685. if (navigator == null)
  686. {
  687. return false;
  688. }
  689. GenericSeekableNavigator nav = navigator as GenericSeekableNavigator;
  690. if (null != nav)
  691. {
  692. return this.navigator.IsDescendant(nav.navigator);
  693. }
  694. return false;
  695. }
  696. public override bool IsSamePosition(XPathNavigator other)
  697. {
  698. GenericSeekableNavigator nav = other as GenericSeekableNavigator;
  699. if (null != nav)
  700. {
  701. return this.navigator.IsSamePosition(nav.navigator);
  702. }
  703. return false;
  704. }
  705. public override void MoveToRoot()
  706. {
  707. this.currentPosition = -1;
  708. this.navigator.MoveToRoot();
  709. }
  710. public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope)
  711. {
  712. this.currentPosition = -1;
  713. return this.navigator.MoveToNextNamespace(namespaceScope);
  714. }
  715. public override bool MoveToNextAttribute()
  716. {
  717. this.currentPosition = -1;
  718. return this.navigator.MoveToNextAttribute();
  719. }
  720. public override bool MoveToPrevious()
  721. {
  722. this.currentPosition = -1;
  723. return this.navigator.MoveToPrevious();
  724. }
  725. public override bool MoveToFirstAttribute()
  726. {
  727. this.currentPosition = -1;
  728. return this.navigator.MoveToFirstAttribute();
  729. }
  730. public override bool MoveToNamespace(string name)
  731. {
  732. this.currentPosition = -1;
  733. return this.navigator.MoveToNamespace(name);
  734. }
  735. public override bool MoveToParent()
  736. {
  737. this.currentPosition = -1;
  738. return this.navigator.MoveToParent();
  739. }
  740. public override bool MoveTo(XPathNavigator other)
  741. {
  742. GenericSeekableNavigator nav = other as GenericSeekableNavigator;
  743. if (null != nav)
  744. {
  745. if (this.navigator.MoveTo(nav.navigator))
  746. {
  747. this.currentPosition = nav.currentPosition;
  748. return true;
  749. }
  750. }
  751. return false;
  752. }
  753. public override bool MoveToId(string id)
  754. {
  755. this.currentPosition = -1;
  756. return this.navigator.MoveToId(id);
  757. }
  758. public override bool MoveToFirstChild()
  759. {
  760. this.currentPosition = -1;
  761. return this.navigator.MoveToFirstChild();
  762. }
  763. public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope)
  764. {
  765. this.currentPosition = -1;
  766. return this.navigator.MoveToFirstNamespace(namespaceScope);
  767. }
  768. public override bool MoveToAttribute(string localName, string namespaceURI)
  769. {
  770. this.currentPosition = -1;
  771. return this.navigator.MoveToAttribute(localName, namespaceURI);
  772. }
  773. public override bool MoveToNext()
  774. {
  775. this.currentPosition = -1;
  776. return this.navigator.MoveToNext();
  777. }
  778. public override bool MoveToFirst()
  779. {
  780. this.currentPosition = -1;
  781. return this.navigator.MoveToFirst();
  782. }
  783. internal void SnapshotNavigator()
  784. {
  785. this.currentPosition = this.dom.nodes.Count;
  786. this.dom.nodes.Add(this.navigator.Clone());
  787. /*
  788. if (this.currentPosition < this.nodes.Count)
  789. {
  790. // Use a cached navigator
  791. XPathNavigator clonedNavigator = this.nodes[(int)this.currentPosition];
  792. Fx.Assert(null != clonedNavigator, "");
  793. clonedNavigator.MoveTo(this);
  794. }
  795. else
  796. {
  797. this.nodes.Add(this.navigator.Clone());
  798. }
  799. */
  800. }
  801. #region IQueryBufferPool Members
  802. #if NO
  803. /// <summary>
  804. /// Reset the pool by deleting it entirely and starting it over
  805. /// </summary>
  806. public void Reset()
  807. {
  808. this.nodes.count = 0;
  809. this.nodes.TrimToCount();
  810. }
  811. public void Trim()
  812. {
  813. this.nodes.TrimToCount();
  814. }
  815. #endif
  816. #endregion
  817. }
  818. }