Update Reference Sources to .NET Framework 4.6.1
[mono.git] / mcs / class / referencesource / System.Xml / System / Xml / XPath / Internal / IteratorFilter.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="IteratorFilter.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>                                                                
5 // <owner current="true" primary="true">[....]</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 class IteratorFilter : XPathNodeIterator {
16         private XPathNodeIterator innerIterator;
17         private string            name;
18         private int               position = 0;
19
20         internal IteratorFilter(XPathNodeIterator innerIterator, string name) {
21             this.innerIterator = innerIterator;
22             this.name          = name;
23         }
24
25         private IteratorFilter(IteratorFilter it) {
26             this.innerIterator = it.innerIterator.Clone();
27             this.name          = it.name;
28             this.position      = it.position;
29         }
30
31         public override XPathNodeIterator Clone()         { return new IteratorFilter(this); }
32         public override XPathNavigator    Current         { get { return innerIterator.Current;} }        
33         public override int               CurrentPosition { get { return this.position; } }
34
35         public override bool MoveNext() {
36             while(innerIterator.MoveNext()) {
37                 if(innerIterator.Current.LocalName == this.name) {
38                     this.position ++;
39                     return true;
40                 }
41             }
42             return false;
43         }
44     }
45 }