Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Xml / System / Xml / XPath / Internal / ResetableIterator.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="ResetableIterator.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>                                                                
5 // <owner current="true" primary="true">Microsoft</owner>
6 //------------------------------------------------------------------------------
7
8 namespace MS.Internal.Xml.XPath {
9     using System;
10     using System.Xml;
11     using System.Xml.XPath;
12     using System.Diagnostics;
13     using System.Globalization;
14
15     internal abstract class ResetableIterator : XPathNodeIterator {
16         // the best place for this constructors to be is XPathNodeIterator, to avoid DCR at this time let's ground them here
17         public ResetableIterator() {
18             base.count = -1;
19         }
20         protected ResetableIterator(ResetableIterator other) {
21             base.count = other.count;
22         }
23         protected void ResetCount() { 
24             base.count = -1; 
25         }
26
27         public abstract void Reset();
28         public virtual bool MoveToPosition(int pos) {
29             Reset();
30             for(int i = CurrentPosition; i < pos ; i ++) {
31                 if(!MoveNext()) {
32                     return false;
33                 }
34             }
35             return true;
36         }
37
38         // Contruct extension: CurrentPosition should return 0 if MoveNext() wasn't called after Reset()
39         // (behavior is not defined for XPathNodeIterator)
40         public abstract override int CurrentPosition { get; }
41     }
42 }