(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Mono.Data.SybaseClient / Mono.Data.SybaseClient / SybaseParameterCollection.cs
blob7b8a06174159b7b3cd52b466e4ec32cf68a815fb
1 //
2 // Mono.Data.SybaseClient.SybaseParameterCollection.cs
3 //
4 // Author:
5 // Rodrigo Moya (rodrigo@ximian.com)
6 // Daniel Morgan (danmorg@sc.rr.com)
7 // Tim Coleman (tim@timcoleman.com)
8 //
9 // (C) Ximian, Inc 2002
10 // Copyright (C) Tim Coleman, 2002
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
21 //
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
24 //
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using Mono.Data.Tds;
35 using System;
36 using System.ComponentModel;
37 using System.Data;
38 using System.Data.Common;
39 using System.Collections;
41 namespace Mono.Data.SybaseClient {
42 [ListBindable (false)]
43 public sealed class SybaseParameterCollection : MarshalByRefObject, IDataParameterCollection, IList, ICollection, IEnumerable
45 #region Fields
47 ArrayList list = new ArrayList();
48 TdsMetaParameterCollection metaParameters;
49 SybaseCommand command;
51 #endregion // Fields
53 #region Constructors
55 internal SybaseParameterCollection (SybaseCommand command)
57 this.command = command;
58 metaParameters = new TdsMetaParameterCollection ();
61 #endregion // Constructors
63 #region Properties
65 public int Count {
66 get { return list.Count; }
69 public SybaseParameter this [int index] {
70 get { return (SybaseParameter) list [index]; }
71 set { list [index] = (SybaseParameter) value; }
74 object IDataParameterCollection.this [string parameterName] {
75 get { return this[parameterName]; }
76 set {
77 if (!(value is SybaseParameter))
78 throw new InvalidCastException ("Only SQLParameter objects can be used.");
79 this [parameterName] = (SybaseParameter) value;
83 public SybaseParameter this [string parameterName] {
84 get {
85 foreach (SybaseParameter p in list)
86 if (p.ParameterName.Equals (parameterName))
87 return p;
88 throw new IndexOutOfRangeException ("The specified name does not exist: " + parameterName);
90 set {
91 if (!Contains (parameterName))
92 throw new IndexOutOfRangeException("The specified name does not exist: " + parameterName);
93 this [IndexOf (parameterName)] = value;
97 object IList.this [int index] {
98 get { return (SybaseParameter) this [index]; }
99 set { this [index] = (SybaseParameter) value; }
102 bool IList.IsFixedSize {
103 get { return list.IsFixedSize; }
106 bool IList.IsReadOnly {
107 get { return list.IsReadOnly; }
110 bool ICollection.IsSynchronized {
111 get { return list.IsSynchronized; }
114 object ICollection.SyncRoot {
115 get { return list.SyncRoot; }
118 internal TdsMetaParameterCollection MetaParameters {
119 get { return metaParameters; }
122 #endregion // Properties
124 #region Methods
126 public int Add (object value)
128 if (!(value is SybaseParameter))
129 throw new InvalidCastException ("The parameter was not an SybaseParameter.");
130 Add ((SybaseParameter) value);
131 return IndexOf (value);
134 public SybaseParameter Add (SybaseParameter value)
136 if (value.Container != null)
137 throw new ArgumentException ("The SybaseParameter specified in the value parameter is already added to this or another SybaseParameterCollection.");
139 value.Container = this;
140 list.Add (value);
141 metaParameters.Add (value.MetaParameter);
142 return value;
145 public SybaseParameter Add (string parameterName, object value)
147 return Add (new SybaseParameter (parameterName, value));
150 public SybaseParameter Add (string parameterName, SybaseType sybaseType)
152 return Add (new SybaseParameter (parameterName, sybaseType));
155 public SybaseParameter Add (string parameterName, SybaseType sybaseType, int size)
157 return Add (new SybaseParameter (parameterName, sybaseType, size));
160 public SybaseParameter Add (string parameterName, SybaseType sybaseType, int size, string sourceColumn)
162 return Add (new SybaseParameter (parameterName, sybaseType, size, sourceColumn));
165 public void Clear()
167 metaParameters.Clear ();
168 list.Clear ();
171 public bool Contains (object value)
173 if (!(value is SybaseParameter))
174 throw new InvalidCastException ("The parameter was not an SybaseParameter.");
175 return Contains (((SybaseParameter) value).ParameterName);
178 public bool Contains (string value)
180 foreach (SybaseParameter p in list)
181 if (p.ParameterName.Equals (value))
182 return true;
183 return false;
186 public void CopyTo (Array array, int index)
188 list.CopyTo (array, index);
191 public IEnumerator GetEnumerator()
193 return list.GetEnumerator ();
196 public int IndexOf (object value)
198 if (!(value is SybaseParameter))
199 throw new InvalidCastException ("The parameter was not an SybaseParameter.");
200 return IndexOf (((SybaseParameter) value).ParameterName);
203 public int IndexOf (string parameterName)
205 return list.IndexOf (parameterName);
208 public void Insert (int index, object value)
210 list.Insert (index, value);
213 public void Remove (object value)
215 metaParameters.Remove (((SybaseParameter) value).MetaParameter);
216 list.Remove (value);
219 public void RemoveAt (int index)
221 metaParameters.RemoveAt (index);
222 list.RemoveAt (index);
225 public void RemoveAt (string parameterName)
227 RemoveAt (IndexOf (parameterName));
230 #endregion // Methods