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