2002-10-30 Tim Coleman (tim@timcoleman.com)
[mono.git] / mcs / class / System.Data / System.Data.Common / DbDataRecord.cs
1 //
2 // System.Data.Common.DbDataRecord.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.ComponentModel;
12 using System.Data;
13
14 namespace System.Data.Common {
15         public class DbDataRecord : IDataRecord, ICustomTypeDescriptor
16         {
17                 #region Fields
18
19                 SchemaInfo[] schema;
20                 object[] values;
21                 int fieldCount;
22                 FieldNameLookup lookup;
23
24                 #endregion
25                 
26                 #region Constructors
27
28                 internal DbDataRecord (SchemaInfo[] schema, object[] values, FieldNameLookup lookup)
29                 {
30                         this.schema = schema;
31                         this.lookup = lookup;
32                         this.values = values;
33                         this.fieldCount = values.Length;
34                 }
35
36                 #endregion
37
38                 #region Properties
39
40                 public int FieldCount {
41                         get { return fieldCount; }
42                 }
43
44                 public object this [string name] {
45                         get { return this [GetOrdinal (name)]; }
46                 }
47
48                 public object this [int index] {
49                         get { return GetValue (index); }
50                 }       
51
52                 #endregion
53
54                 #region Methods
55
56                 public bool GetBoolean (int i)
57                 {
58                         return (bool) GetValue (i);
59                 }
60
61                 public byte GetByte (int i)
62                 {
63                         return (byte) GetValue (i);
64                 }
65         
66                 [MonoTODO]      
67                 public long GetBytes (int i, long dataIndex, byte[] buffer, int bufferIndex, int length)
68                 {
69                         throw new NotImplementedException ();
70                 }
71
72                 public char GetChar (int i)
73                 {
74                         return (char) GetValue (i);
75                 }
76
77                 [MonoTODO]
78                 public long GetChars (int i, long dataIndex, char[] buffer, int bufferIndex, int length)
79                 {
80                         throw new NotImplementedException ();
81                 }
82
83                 [MonoTODO]
84                 public IDataReader GetData (int i)
85                 {
86                         throw new NotImplementedException ();
87                 }
88
89                 public string GetDataTypeName (int i)
90                 {
91                         return schema[i].DataTypeName;
92                 }
93
94                 public DateTime GetDateTime (int i)
95                 {
96                         return (DateTime) GetValue (i); 
97                 }
98
99                 public decimal GetDecimal (int i)
100                 {
101                         return (decimal) GetValue (i);
102                 }
103
104                 public double GetDouble (int i)
105                 {
106                         return (double) GetValue (i);
107                 }
108
109                 public Type GetFieldType (int i)
110                 {
111                         return GetValue (i).GetType ();
112                 }
113
114                 public float GetFloat (int i)
115                 {
116                         return (float) GetValue (i);
117                 }
118                 
119                 public Guid GetGuid (int i)
120                 {
121                         return (Guid) GetValue (i);
122                 }
123                 
124                 public short GetInt16 (int i)
125                 {
126                         return (short) GetValue (i); 
127                 }
128         
129                 public int GetInt32 (int i)
130                 {
131                         return (int) GetValue (i); 
132                 }
133
134                 public long GetInt64 (int i)
135                 {
136                         return (long) GetValue (i); 
137                 }
138
139                 public string GetName (int i)
140                 {
141                         return (string) lookup [i];
142                 }
143
144                 public int GetOrdinal (string name)
145                 {
146                         return lookup.IndexOf (name);
147                 }
148
149                 public string GetString (int i)
150                 {
151                         return (string) GetValue (i);
152                 }
153
154                 public object GetValue (int i)
155                 {
156                         return values [i];
157                 }
158
159                 [MonoTODO]
160                 public int GetValues (object[] values)
161                 {
162                         throw new NotImplementedException ();
163                 }
164
165                 [MonoTODO]
166                 AttributeCollection ICustomTypeDescriptor.GetAttributes ()
167                 {
168                         throw new NotImplementedException ();
169                 }
170
171                 [MonoTODO]
172                 string ICustomTypeDescriptor.GetClassName ()
173                 {
174                         throw new NotImplementedException ();
175                 }
176
177                 [MonoTODO]
178                 string ICustomTypeDescriptor.GetComponentName ()
179                 {
180                         throw new NotImplementedException ();
181                 }
182
183                 [MonoTODO]
184                 TypeConverter ICustomTypeDescriptor.GetConverter ()
185                 {
186                         throw new NotImplementedException ();
187                 }       
188
189                 [MonoTODO]
190                 EventDescriptor ICustomTypeDescriptor.GetDefaultEvent ()
191                 {
192                         throw new NotImplementedException ();
193                 }       
194
195                 [MonoTODO]
196                 PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty ()
197                 {
198                         throw new NotImplementedException ();
199                 }       
200
201                 [MonoTODO]
202                 object ICustomTypeDescriptor.GetEditor (Type editorBaseType)
203                 {
204                         throw new NotImplementedException ();
205                 }       
206
207                 [MonoTODO]
208                 EventDescriptorCollection ICustomTypeDescriptor.GetEvents ()
209                 {
210                         throw new NotImplementedException ();
211                 }       
212
213                 [MonoTODO]
214                 EventDescriptorCollection ICustomTypeDescriptor.GetEvents (Attribute[] attributes)
215                 {
216                         throw new NotImplementedException ();
217                 }       
218
219                 [MonoTODO]
220                 PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties ()
221                 {
222                         throw new NotImplementedException ();
223                 }       
224
225                 [MonoTODO]
226                 PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties (Attribute[] attributes)
227                 {
228                         throw new NotImplementedException ();
229                 }       
230
231                 [MonoTODO]
232                 object ICustomTypeDescriptor.GetPropertyOwner (PropertyDescriptor pd)
233                 {
234                         throw new NotImplementedException ();
235                 }       
236
237                 public bool IsDBNull (int i)
238                 {
239                         return GetValue (i) == null;
240                 }
241
242                 #endregion // Methods
243         }
244 }