2 // Mono.Data.TdsClient.TdsParameterCollection.cs
5 // Tim Coleman (tim@timcoleman.com)
7 // Copyright (C) Tim Coleman, 2002
10 using Mono.Data.TdsClient.Internal;
12 using System.Collections;
13 using System.ComponentModel;
15 using System.Data.Common;
16 using System.Runtime.InteropServices;
18 namespace Mono.Data.TdsClient {
19 public sealed class TdsParameterCollection : MarshalByRefObject, IDataParameterCollection, IList, ICollection, IEnumerable
23 ArrayList list = new ArrayList ();
30 get { return list.Count; }
33 object IList.this [int index] {
34 get { return (TdsParameter) this[index]; }
35 set { this[index] = (TdsParameter) value; }
38 public TdsParameter this [int index] {
41 throw new IndexOutOfRangeException ();
42 return (TdsParameter) list[index];
46 throw new IndexOutOfRangeException ();
47 list[index] = (TdsParameter) value;
51 object IDataParameterCollection.this [string parameterName] {
52 get { return (TdsParameter) this[parameterName]; }
53 set { this [parameterName] = (TdsParameter) value; }
56 public TdsParameter this [string parameterName] {
57 get { return this[IndexOf (parameterName)]; }
58 set { this[IndexOf (parameterName)] = value; }
61 bool IList.IsFixedSize {
65 bool IList.IsReadOnly {
69 bool ICollection.IsSynchronized {
71 get { throw new NotImplementedException (); }
74 object ICollection.SyncRoot {
76 get { throw new NotImplementedException (); }
79 #endregion // Properties
83 public int Add (object value)
85 if (!(value is TdsParameter))
86 throw new InvalidCastException ();
87 Add ((TdsParameter) value);
88 return IndexOf (value);
91 public TdsParameter Add (TdsParameter value)
97 public TdsParameter Add (string parameterName, object value)
99 return Add (new TdsParameter (parameterName, value));
107 public bool Contains (object value)
109 return list.Contains (value);
112 public bool Contains (string value)
114 return (IndexOf (value) >= 0);
117 public void CopyTo (Array array, int index)
119 throw new NotImplementedException ();
122 public IEnumerator GetEnumerator ()
124 return list.GetEnumerator ();
127 public int IndexOf (object value)
129 return list.IndexOf (value);
132 public int IndexOf (string parameterName)
134 for (int i = 0; i < list.Count; i += 1)
135 if (((TdsParameter) list[i]).ParameterName == parameterName)
140 public void Insert (int index, object value)
142 list.Insert (index, value);
145 public void Remove (object value)
150 public void RemoveAt (int index)
152 list.RemoveAt (index);
155 public void RemoveAt (string parameterName)
157 RemoveAt (IndexOf (parameterName));
161 #endregion // Methods