Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Data.SqlXml / System / Xml / Xsl / Runtime / XmlIterators.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="XmlIterators.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 // <owner current="true" primary="true">Microsoft</owner>
6 //------------------------------------------------------------------------------
7 using System;
8 using System.Xml;
9 using System.Xml.XPath;
10 using System.ComponentModel;
11
12 namespace System.Xml.Xsl.Runtime {
13
14     /// <summary>
15     /// Iterators that use containment to control a nested iterator return one of the following values from MoveNext().
16     /// </summary>
17     [EditorBrowsable(EditorBrowsableState.Never)]
18     public enum IteratorResult {
19         NoMoreNodes,                // Iteration is complete; there are no more nodes
20         NeedInputNode,              // The next node needs to be fetched from the contained iterator before iteration can continue
21         HaveCurrentNode,            // This iterator's Current property is set to the next node in the iteration
22     };
23
24
25     /// <summary>
26     /// Tokenize a string containing IDREF values and deref the values in order to get a list of ID elements.
27     /// </summary>
28     [EditorBrowsable(EditorBrowsableState.Never)]
29     public struct IdIterator {
30         private XPathNavigator navCurrent;
31         private string[] idrefs;
32         private int idx;
33
34         public void Create(XPathNavigator context, string value) {
35             this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, context);
36             this.idrefs = XmlConvert.SplitString(value);
37             this.idx = -1;
38         }
39
40         public bool MoveNext() {
41             do {
42                 this.idx++;
43                 if (this.idx >= idrefs.Length)
44                     return false;
45             }
46             while (!this.navCurrent.MoveToId(this.idrefs[this.idx]));
47
48             return true;
49         }
50
51         /// <summary>
52         /// Return the current result navigator.  This is only defined after MoveNext() has returned true.
53         /// </summary>
54         public XPathNavigator Current {
55             get { return this.navCurrent; }
56         }
57     }
58 }