source: BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/cs/bmx_0200scr/BMX2/BMXNet/BMXNetParameterCollection.cs@ 1182

Last change on this file since 1182 was 815, checked in by Sam Habiel, 14 years ago

Initial commit of C# Source Code. Now to try to get it to compile.

File size: 1.9 KB
Line 
1using System;
2using System.Data;
3using System.Collections;
4using System.Globalization;
5
6namespace IndianHealthService.BMXNet
7{
8 /*
9 * Because IDataParameterCollection is primarily an IList,
10 * the sample can use an existing class for most of the implementation.
11 */
12 public class BMXNetParameterCollection : ArrayList, IDataParameterCollection
13 {
14 public object this[string index]
15 {
16 get
17 {
18 return this[IndexOf(index)];
19 }
20 set
21 {
22 this[IndexOf(index)] = value;
23 }
24 }
25
26 public bool Contains(string parameterName)
27 {
28 return(-1 != IndexOf(parameterName));
29 }
30
31 public int IndexOf(string parameterName)
32 {
33 int index = 0;
34 foreach(BMXNetParameter item in this)
35 {
36 if (0 == _cultureAwareCompare(item.ParameterName, parameterName))
37 {
38 return index;
39 }
40 index++;
41 }
42 return -1;
43 }
44
45 public void RemoveAt(string parameterName)
46 {
47 RemoveAt(IndexOf(parameterName));
48 }
49
50 public override int Add(object value)
51 {
52 return Add((BMXNetParameter)value);
53 }
54
55 public int Add(BMXNetParameter value)
56 {
57 if (((BMXNetParameter)value).ParameterName != null)
58 {
59 return base.Add(value);
60 }
61 else
62 throw new ArgumentException("parameter must be named");
63 }
64
65 public int Add(string parameterName, DbType type)
66 {
67 return Add(new BMXNetParameter(parameterName, type));
68 }
69
70 public int Add(string parameterName, object value)
71 {
72 return Add(new BMXNetParameter(parameterName, value));
73 }
74
75 public int Add(string parameterName, DbType dbType, string sourceColumn)
76 {
77 return Add(new BMXNetParameter(parameterName, dbType, sourceColumn));
78 }
79
80 private int _cultureAwareCompare(string strA, string strB)
81 {
82 return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase);
83 }
84 }
85}
Note: See TracBrowser for help on using the repository browser.