2004-05-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / DataSourceInternal.cs
1 /**
2  * Namespace:   System.Web.UI.WebControls
3  * Class:       DataSourceInternal
4  *
5  * Author:      Gaurav Vaish
6  * Maintainer:  gvaish_mono@lycos.com
7  * Contact:     gvaish_mono@lycos.com
8  * Implementation: Yes
9  * Status:      100%
10  *
11  * (C) Gaurav Vaish (2002)
12  */
13
14 using System;
15 using System.Collections;
16 using System.Web;
17 using System.Web.UI;
18
19 namespace System.Web.UI.WebControls
20 {
21         internal class DataSourceInternal : ICollection, IEnumerable
22         {
23                 private int itemCount;
24
25                 public DataSourceInternal(int itemCount)
26                 {
27                         this.itemCount = itemCount;
28                 }
29
30                 public int Count
31                 {
32                         get
33                         {
34                                 return itemCount;
35                         }
36                 }
37
38                 public bool IsReadOnly
39                 {
40                         get
41                         {
42                                 return false;
43                         }
44                 }
45
46                 public bool IsSynchronized
47                 {
48                         get
49                         {
50                                 return false;
51                         }
52                 }
53
54                 public object SyncRoot
55                 {
56                         get
57                         {
58                                 return this;
59                         }
60                 }
61
62                 public void CopyTo(Array array, int index)
63                 {
64                         IEnumerator e = GetEnumerator();
65                         while(e.MoveNext())
66                         {
67                                 array.SetValue(e.Current, index);
68                                 index++;
69                         }
70                 }
71                 
72                 public IEnumerator GetEnumerator()
73                 {
74                         return new DataSourceEnumeratorInternal(itemCount);
75                 }
76                 
77                 private class DataSourceEnumeratorInternal : IEnumerator
78                 {
79                         private int count;
80                         private int index;
81                         
82                         public DataSourceEnumeratorInternal(int count)
83                         {
84                                 this.count = count;
85                                 this.index = -1;
86                         }
87                         
88                         public bool MoveNext()
89                         {
90                                 index++;
91                                 return (index < count);
92                         }
93                         
94                         public object Current
95                         {
96                                 get
97                                 {
98                                         return null;
99                                 }
100                         }
101                         
102                         public void Reset()
103                         {
104                                 this.index = -1;
105                         }
106                 }
107         }
108 }