1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 
5 using System;
6 using System.Diagnostics;
7 
8 namespace System.Xml.Xsl.Qil
9 {
10     /// <summary>
11     /// View over a Qil iterator node (For or Let).
12     /// </summary>
13     internal class QilIterator : QilReference
14     {
15         private QilNode _binding;
16 
17         //-----------------------------------------------
18         // Constructor
19         //-----------------------------------------------
20 
21         /// <summary>
22         /// Construct an iterator
23         /// </summary>
QilIterator(QilNodeType nodeType, QilNode binding)24         public QilIterator(QilNodeType nodeType, QilNode binding) : base(nodeType)
25         {
26             Binding = binding;
27         }
28 
29 
30         //-----------------------------------------------
31         // IList<QilNode> methods -- override
32         //-----------------------------------------------
33 
34         public override int Count
35         {
36             get { return 1; }
37         }
38 
39         public override QilNode this[int index]
40         {
41             get { if (index != 0) throw new IndexOutOfRangeException(); return _binding; }
42             set { if (index != 0) throw new IndexOutOfRangeException(); _binding = value; }
43         }
44 
45 
46         //-----------------------------------------------
47         // QilIterator methods
48         //-----------------------------------------------
49 
50         /// <summary>
51         /// Expression which is bound to the iterator.
52         /// </summary>
53         public QilNode Binding
54         {
55             get { return _binding; }
56             set { _binding = value; }
57         }
58     }
59 }
60