XPathNodeIterator.cs 929 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // System.Xml.XPath.XPathNodeIterator
  3. //
  4. // Author:
  5. // Jason Diamond ([email protected])
  6. //
  7. // (C) 2002 Jason Diamond http://injektilo.org/
  8. //
  9. using System;
  10. namespace System.Xml.XPath
  11. {
  12. public abstract class XPathNodeIterator : ICloneable
  13. {
  14. private int _count = -1;
  15. #region Constructor
  16. protected XPathNodeIterator ()
  17. {
  18. }
  19. #endregion
  20. #region Properties
  21. public virtual int Count
  22. {
  23. get
  24. {
  25. if (_count == -1)
  26. {
  27. // compute and cache the count
  28. XPathNodeIterator tmp = Clone ();
  29. while (tmp.MoveNext ())
  30. ;
  31. _count = tmp.CurrentPosition;
  32. }
  33. return _count;
  34. }
  35. }
  36. public abstract XPathNavigator Current { get; }
  37. public abstract int CurrentPosition { get; }
  38. #endregion
  39. #region Methods
  40. public abstract XPathNodeIterator Clone ();
  41. object ICloneable.Clone ()
  42. {
  43. return Clone ();
  44. }
  45. public abstract bool MoveNext ();
  46. #endregion
  47. }
  48. }