2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / Mono.Data.Tds / Mono.Data.Tds / TdsMetaParameterCollection.cs
1 //
2 // Mono.Data.Tds.TdsMetaParameter.cs
3 //
4 // Author:
5 //   Tim Coleman (tim@timcoleman.com)
6 //
7 // Copyright (C) Tim Coleman, 2002
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using System;
32 using System.Collections;
33
34 namespace Mono.Data.Tds {
35         public class TdsMetaParameterCollection : ICollection, IEnumerable
36         {
37                 #region Fields
38
39                 ArrayList list;
40
41                 #endregion // Fields
42
43                 public TdsMetaParameterCollection ()
44                 {
45                         list = new ArrayList ();
46                 }
47
48                 #region Properties
49
50                 public int Count {
51                         get { return list.Count; }
52                 }
53
54                 public bool IsSynchronized {
55                         get { return list.IsSynchronized; }
56                 }
57                 
58                 public TdsMetaParameter this [int index] {
59                         get { return (TdsMetaParameter) list [index]; }
60                 }
61
62                 public TdsMetaParameter this [string name] {
63                         get { return (TdsMetaParameter) this [IndexOf (name)]; }
64                 }
65
66                 public object SyncRoot {
67                         get { return list.SyncRoot; }
68                 }
69
70                 #endregion // Properties
71
72                 #region Methods
73
74                 public int Add (TdsMetaParameter value)
75                 {
76                         return list.Add (value); 
77                 }
78
79                 public void Clear ()
80                 {
81                         list.Clear ();  
82                 }
83
84                 public bool Contains (TdsMetaParameter value)
85                 {
86                         return list.Contains (value);
87                 }
88
89                 public void CopyTo (Array array, int index) 
90                 {
91                         list.CopyTo (array, index);
92                 }
93
94                 IEnumerator IEnumerable.GetEnumerator ()
95                 {
96                         return list.GetEnumerator ();
97                 }
98
99                 public int IndexOf (TdsMetaParameter value)
100                 {
101                         return list.IndexOf (value);
102                 }
103
104                 public int IndexOf (string name)
105                 {
106                         for (int i = 0; i < Count; i += 1)
107                                 if (this [i].ParameterName.Equals (name))
108                                         return i;
109                         return -1;
110                 }
111
112                 public void Insert (int index, TdsMetaParameter value)
113                 {
114                         list.Insert (index, value);
115                 }
116
117                 public void Remove (TdsMetaParameter value)
118                 {
119                         list.Remove (value);
120                 }
121
122                 public void Remove (string name)
123                 {
124                         RemoveAt (IndexOf (name));
125                 }
126
127                 public void RemoveAt (int index)
128                 {
129                         list.RemoveAt (index);
130                 }
131
132                 #endregion // Methods
133         }
134 }