Add CodeDom implementation
[mono.git] / mcs / class / System / System.CodeDom / CodeExpressionCollection.cs
1 //
2 // System.CodeDOM CodeExpressionCollection Class implementation
3 //
4 // Author:
5 //   Miguel de Icaza (miguel@ximian.com)
6 //
7 // (C) 2001 Ximian, Inc.
8 //
9
10 namespace System.CodeDOM {
11
12         using System.Collections;
13         
14         public class CodeExpressionCollection : IList, ICollection, IEnumerable {
15
16                 ArrayList expressions;
17                 
18                 //
19                 // Constructors
20                 //
21                 public CodeExpressionCollection ()
22                 {
23                         expressions = new ArrayList ();
24                 }
25
26                 //
27                 // Properties
28                 //
29                 public int Count {
30                         get {
31                                 return expressions.Count;
32                         }
33                 }
34
35                 //
36                 // Methods
37                 //
38                 public void Add (CodeExpression value)
39                 {
40                         expressions.Add (value);
41                 }
42
43                 public void AddRange (CodeExpression [] values)
44                 {
45                         foreach (CodeExpression ca in values) 
46                                 expressions.Add (ca);
47
48                 }
49
50                 public void Clear ()
51                 {
52                         expressions.Clear ();
53                 }
54
55                 private class Enumerator : IEnumerator {
56                         private CodeExpressionCollection collection;
57                         private int currentIndex = -1;
58
59                         internal Enumerator (CodeExpressionCollection collection)
60                         {
61                                 this.collection = collection;
62                         }
63
64                         public object Current {
65                                 get {
66                                         if (currentIndex == collection.Count)
67                                                 throw new InvalidOperationException ();
68                                         return collection [currentIndex];
69                                 }
70                         }
71
72                         public bool MoveNext ()
73                         {
74                                 if (currentIndex > collection.Count)
75                                         throw new InvalidOperationException ();
76                                 return ++currentIndex < collection.Count;
77                         }
78
79                         public void Reset ()
80                         {
81                                 currentIndex = -1;
82                         }
83                 }
84                 
85                 public IEnumerator GetEnumerator ()
86                 {
87                         return new CodeExpressionCollection.Enumerator (this);
88                 }
89
90                 //
91                 // IList method implementations
92                 //
93                 public int Add (object value)
94                 {
95                         return expressions.Add (value);
96                 }
97
98                 public bool Contains (Object value)
99                 {
100                         return expressions.Contains (value);
101                 }
102
103                 public int IndexOf (Object value)
104                 {
105                         return expressions.IndexOf (value);
106                 }
107
108                 public void Insert (int index, Object value)
109                 {
110                         expressions [index] = value;
111                 }
112
113                 public object this[int index] {
114                         get {
115                                 return expressions [index];
116                         }
117
118                         set {
119                                 expressions [index] = value;
120                         }
121                 }
122
123                 public void Remove (object value)
124                 {
125                         expressions.Remove (value);
126                 }
127
128                 public void RemoveAt (int index)
129                 {
130                         expressions.RemoveAt (index);
131                 }
132
133                 //
134                 // ICollection method implementations
135                 //
136                 public void CopyTo (Array array, int index)
137                 {
138                         expressions.CopyTo (array, index);
139                 }
140
141                 public object SyncRoot {
142                         get {
143                                 return expressions.SyncRoot;
144                         }
145                 }
146
147                 public bool IsReadOnly {
148                         get {
149                                 return false;
150                         }
151                 }
152
153                 public bool IsSynchronized {
154                         get {
155                                 return expressions.IsSynchronized;
156                         }
157                 }
158         }
159 }