disable broken tests on net_4_0
[mcs.git] / class / IBM.Data.DB2 / IBM.Data.DB2 / DB2ParameterCollection.cs
blobbb1f09d483297335d179dde74ef7aa938df46cdd
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining
4 // a copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to
8 // permit persons to whom the Software is furnished to do so, subject to
9 // the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be
12 // included in all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 using System;
23 using System.Data;
24 using System.Collections;
25 using System.Globalization;
28 namespace IBM.Data.DB2
31 public class DB2ParameterCollection : ArrayList, IDataParameterCollection
33 IntPtr hwndStmt = IntPtr.Zero;
35 internal IntPtr HwndStmt
37 set
39 hwndStmt = value;
42 public new DB2Parameter this[int index]
44 get
46 return (DB2Parameter)base[index];
48 set
50 base[index] = value;
53 public DB2Parameter this[string index]
55 get
57 return (DB2Parameter)base[IndexOf(index)];
59 set
61 base[IndexOf(index)] = value;
64 object IDataParameterCollection.this[string index]
66 get
68 return this[IndexOf(index)];
70 set
72 this[IndexOf(index)] = (DB2Parameter)value;
75 public bool Contains(string paramName)
77 return(-1 != IndexOf(paramName));
80 public int IndexOf(string paramName)
82 int index = 0;
83 for(index = 0; index < Count; index++)
85 if (0 == _cultureAwareCompare(((DB2Parameter)this[index]).ParameterName, paramName))
87 return index;
90 return -1;
93 public void RemoveAt(string paramName)
95 RemoveAt(IndexOf(paramName));
98 public override int Add(object obj)
100 DB2Parameter value = (DB2Parameter)obj;
101 if(value.ParameterName == null)
102 throw new ArgumentException("parameter must be named");
103 if(IndexOf(value.ParameterName) >= 0)
104 throw new ArgumentException("parameter name is already in collection");
105 return base.Add(value);
108 public DB2Parameter Add(DB2Parameter value)
110 if(value.ParameterName == null)
111 throw new ArgumentException("parameter must be named");
112 if(IndexOf(value.ParameterName) >= 0)
113 throw new ArgumentException("parameter name is already in collection");
114 base.Add(value);
115 return value;
118 public DB2Parameter Add(string paramName, DB2Type type)
120 return Add(new DB2Parameter(paramName, type));
123 public DB2Parameter Add(string paramName, object value)
125 return Add(new DB2Parameter(paramName, value));
128 public DB2Parameter Add(string paramName, DB2Type dbType, int size)
130 return Add(new DB2Parameter(paramName, dbType, size));
133 public DB2Parameter Add(string paramName, DB2Type dbType, int size, string sourceColumn)
135 return Add(new DB2Parameter(paramName, dbType, size, sourceColumn));
138 private int _cultureAwareCompare(string strA, string strB)
140 return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase);
143 internal void GetOutValues()
145 foreach(DB2Parameter param in this)
147 if(ParameterDirection.Output == param.Direction || ParameterDirection.InputOutput == param.Direction)
149 param.GetOutValue();
150 //Console.WriteLine(param.ParameterName);