2004-04-22 Martin Baulig <martin@ximian.com>
[mono.git] / mcs / class / System.Data / System.Data.Common / FieldNameLookup.cs
1 //
2 // System.Data.Common.FieldNameLookup.cs
3 //
4 // Author:
5 //   Tim Coleman (tim@timcoleman.com)
6 //
7 // Copyright (C) Tim Coleman, 2002
8 //
9
10 using System.Collections;
11 using System.Data;
12
13 namespace System.Data.Common {
14 #if NET_2_0
15 // FIXME: Need to clean this up
16         public sealed class FieldNameLookup
17 #else
18         internal sealed class FieldNameLookup : ICollection, IEnumerable
19 #endif
20         {
21                 #region Fields
22
23                 ArrayList list;
24
25                 #endregion
26                 
27                 #region Constructors
28
29                 public FieldNameLookup ()
30                 {
31                         list = new ArrayList ();
32                 }
33
34                 public FieldNameLookup (DataTable schemaTable)
35                         : this ()
36                 {
37                         foreach (DataRow row in schemaTable.Rows)
38                                 list.Add ((string) row["ColumnName"]);
39                 }
40
41                 #endregion
42
43                 #region Properties
44
45                 public int Count {
46                         get { return list.Count; }
47                 }
48
49                 public bool IsFixedSize {
50                         get { return false; }
51                 }
52
53                 public bool IsReadOnly {
54                         get { return false; }
55                 }
56
57                 public bool IsSynchronized {
58                         get { return list.IsSynchronized; }
59                 }
60
61                 public string this [int index] {
62                         get { return (string) list[index]; }
63                         set { list[index] = value; }
64                 }
65
66                 public object SyncRoot {        
67                         get { return list.SyncRoot; }
68                 }
69
70                 #endregion
71
72                 #region Methods
73
74                 public int Add (object value) 
75                 {
76                         return list.Add (value); 
77                 }
78
79                 public void Clear ()
80                 {
81                         list.Clear ();
82                 }
83
84                 public bool Contains (object 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 #if ONLY_1_0 || ONLY_1_1
95                 IEnumerator IEnumerable.GetEnumerator ()
96                 {
97                         return list.GetEnumerator (); 
98                 }
99 #endif
100
101                 public int IndexOf (object value)
102                 {
103                         return list.IndexOf (value);
104                 }
105
106                 public void Insert (int index, object value)
107                 {
108                         list.Insert (index, value);
109                 }
110
111                 public void Remove (object value)
112                 { 
113                         list.Remove (value);
114                 }
115
116                 public void RemoveAt (int index) 
117                 {
118                         list.RemoveAt (index);
119                 }
120
121                 #endregion // Methods
122         }
123 }