1 //------------------------------------------------------------------------------
2 // <copyright file="XPathSelectionIterator.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">Microsoft</owner>
6 //------------------------------------------------------------------------------
8 namespace MS
.Internal
.Xml
.XPath
{
11 using System
.Xml
.XPath
;
12 using System
.Diagnostics
;
13 using System
.Globalization
;
15 // We need this wrapper object to:
16 // 1. Calculate position
17 // 2. Protect internal query.Current from user who may call MoveNext().
18 internal class XPathSelectionIterator
: ResetableIterator
{
19 private XPathNavigator nav
;
23 internal XPathSelectionIterator(XPathNavigator nav
, Query query
) {
24 this.nav
= nav
.Clone();
28 protected XPathSelectionIterator(XPathSelectionIterator it
) {
29 this.nav
= it
.nav
.Clone();
30 this.query
= (Query
) it
.query
.Clone();
31 this.position
= it
.position
;
34 public override void Reset() {
38 public override bool MoveNext() {
39 XPathNavigator n
= query
.Advance();
50 public override int Count { get { return query.Count; }
}
51 public override XPathNavigator Current { get { return nav; }
}
52 public override int CurrentPosition { get { return position; }
}
53 public override XPathNodeIterator
Clone() { return new XPathSelectionIterator(this); }