2 // System.CodeDOM CodeExpressionCollection Class implementation
5 // Miguel de Icaza (miguel@ximian.com)
7 // (C) 2001 Ximian, Inc.
10 namespace System.CodeDOM {
12 using System.Collections;
14 public class CodeExpressionCollection : IList, ICollection, IEnumerable {
16 ArrayList expressions;
21 public CodeExpressionCollection ()
23 expressions = new ArrayList ();
31 return expressions.Count;
38 public void Add (CodeExpression value)
40 expressions.Add (value);
43 public void AddRange (CodeExpression [] values)
45 foreach (CodeExpression ca in values)
55 private class Enumerator : IEnumerator {
56 private CodeExpressionCollection collection;
57 private int currentIndex = -1;
59 internal Enumerator (CodeExpressionCollection collection)
61 this.collection = collection;
64 public object Current {
66 if (currentIndex == collection.Count)
67 throw new InvalidOperationException ();
68 return collection [currentIndex];
72 public bool MoveNext ()
74 if (currentIndex > collection.Count)
75 throw new InvalidOperationException ();
76 return ++currentIndex < collection.Count;
85 public IEnumerator GetEnumerator ()
87 return new CodeExpressionCollection.Enumerator (this);
91 // IList method implementations
93 public int Add (object value)
95 return expressions.Add (value);
98 public bool Contains (Object value)
100 return expressions.Contains (value);
103 public int IndexOf (Object value)
105 return expressions.IndexOf (value);
108 public void Insert (int index, Object value)
110 expressions [index] = value;
113 public object this[int index] {
115 return expressions [index];
119 expressions [index] = value;
123 public void Remove (object value)
125 expressions.Remove (value);
128 public void RemoveAt (int index)
130 expressions.RemoveAt (index);
134 // ICollection method implementations
136 public void CopyTo (Array array, int index)
138 expressions.CopyTo (array, index);
141 public object SyncRoot {
143 return expressions.SyncRoot;
147 public bool IsReadOnly {
153 public bool IsSynchronized {
155 return expressions.IsSynchronized;