1 //------------------------------------------------------------------------------
2 // <copyright file="XPathArrayIterator.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">Microsoft</owner>
6 //------------------------------------------------------------------------------
9 using System.Collections;
10 using System.Diagnostics;
13 using System.Xml.XPath;
15 namespace MS.Internal.Xml.XPath {
17 [DebuggerDisplay("Position={CurrentPosition}, Current={debuggerDisplayProxy, nq}")]
18 internal class XPathArrayIterator : ResetableIterator {
22 public XPathArrayIterator(IList list) {
26 public XPathArrayIterator(XPathArrayIterator it) {
28 this.index = it.index;
31 public XPathArrayIterator(XPathNodeIterator nodeIterator) {
32 this.list = new ArrayList();
33 while (nodeIterator.MoveNext()) {
34 this.list.Add(nodeIterator.Current.Clone());
39 get { return this.list; }
42 public override XPathNodeIterator Clone() {
43 return new XPathArrayIterator(this);
46 public override XPathNavigator Current {
48 Debug.Assert(index <= list.Count);
51 throw new InvalidOperationException(Res.GetString(Res.Sch_EnumNotStarted, string.Empty));
53 return (XPathNavigator) list[index - 1];
57 public override int CurrentPosition { get { return index; } }
58 public override int Count { get { return list.Count; } }
60 public override bool MoveNext() {
61 Debug.Assert(index <= list.Count);
62 if (index == list.Count) {
69 public override void Reset() {
73 public override IEnumerator GetEnumerator() {
74 return list.GetEnumerator();
77 private object debuggerDisplayProxy { get { return index < 1 ? null : (object)new XPathNavigator.DebuggerDisplayProxy(Current); } }