DbDataRecord.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. //
  2. // System.Data.Common.DbDataRecord.cs
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2002
  8. //
  9. using System.Collections;
  10. using System.ComponentModel;
  11. using System.Data;
  12. namespace System.Data.Common {
  13. public class DbDataRecord : IDataRecord, ICustomTypeDescriptor
  14. {
  15. #region Fields
  16. SchemaInfo[] schema;
  17. object[] values;
  18. int fieldCount;
  19. FieldNameLookup lookup;
  20. #endregion
  21. #region Constructors
  22. internal DbDataRecord (SchemaInfo[] schema, object[] values, FieldNameLookup lookup)
  23. {
  24. this.schema = schema;
  25. this.lookup = lookup;
  26. this.values = values;
  27. this.fieldCount = values.Length;
  28. }
  29. #endregion
  30. #region Properties
  31. public int FieldCount {
  32. get { return fieldCount; }
  33. }
  34. public object this [string name] {
  35. get { return this [GetOrdinal (name)]; }
  36. }
  37. public object this [int index] {
  38. get { return GetValue (index); }
  39. }
  40. #endregion
  41. #region Methods
  42. public bool GetBoolean (int i)
  43. {
  44. return (bool) GetValue (i);
  45. }
  46. public byte GetByte (int i)
  47. {
  48. return (byte) GetValue (i);
  49. }
  50. [MonoTODO]
  51. public long GetBytes (int i, long dataIndex, byte[] buffer, int bufferIndex, int length)
  52. {
  53. throw new NotImplementedException ();
  54. }
  55. public char GetChar (int i)
  56. {
  57. return (char) GetValue (i);
  58. }
  59. [MonoTODO]
  60. public long GetChars (int i, long dataIndex, char[] buffer, int bufferIndex, int length)
  61. {
  62. throw new NotImplementedException ();
  63. }
  64. [MonoTODO]
  65. public IDataReader GetData (int i)
  66. {
  67. throw new NotImplementedException ();
  68. }
  69. public string GetDataTypeName (int i)
  70. {
  71. return schema[i].DataTypeName;
  72. }
  73. public DateTime GetDateTime (int i)
  74. {
  75. return (DateTime) GetValue (i);
  76. }
  77. public decimal GetDecimal (int i)
  78. {
  79. return (decimal) GetValue (i);
  80. }
  81. public double GetDouble (int i)
  82. {
  83. return (double) GetValue (i);
  84. }
  85. public Type GetFieldType (int i)
  86. {
  87. return schema[i].FieldType;
  88. }
  89. public float GetFloat (int i)
  90. {
  91. return (float) GetValue (i);
  92. }
  93. public Guid GetGuid (int i)
  94. {
  95. return (Guid) GetValue (i);
  96. }
  97. public short GetInt16 (int i)
  98. {
  99. return (short) GetValue (i);
  100. }
  101. public int GetInt32 (int i)
  102. {
  103. return (int) GetValue (i);
  104. }
  105. public long GetInt64 (int i)
  106. {
  107. return (long) GetValue (i);
  108. }
  109. public string GetName (int i)
  110. {
  111. return (string) lookup [i];
  112. }
  113. public int GetOrdinal (string name)
  114. {
  115. return lookup.IndexOf (name);
  116. }
  117. public string GetString (int i)
  118. {
  119. return (string) GetValue (i);
  120. }
  121. public object GetValue (int i)
  122. {
  123. return values [i];
  124. }
  125. [MonoTODO]
  126. public int GetValues (object[] values)
  127. {
  128. throw new NotImplementedException ();
  129. }
  130. [MonoTODO]
  131. AttributeCollection ICustomTypeDescriptor.GetAttributes ()
  132. {
  133. throw new NotImplementedException ();
  134. }
  135. [MonoTODO]
  136. string ICustomTypeDescriptor.GetClassName ()
  137. {
  138. throw new NotImplementedException ();
  139. }
  140. [MonoTODO]
  141. string ICustomTypeDescriptor.GetComponentName ()
  142. {
  143. throw new NotImplementedException ();
  144. }
  145. [MonoTODO]
  146. TypeConverter ICustomTypeDescriptor.GetConverter ()
  147. {
  148. throw new NotImplementedException ();
  149. }
  150. [MonoTODO]
  151. EventDescriptor ICustomTypeDescriptor.GetDefaultEvent ()
  152. {
  153. throw new NotImplementedException ();
  154. }
  155. [MonoTODO]
  156. PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty ()
  157. {
  158. throw new NotImplementedException ();
  159. }
  160. [MonoTODO]
  161. object ICustomTypeDescriptor.GetEditor (Type editorBaseType)
  162. {
  163. throw new NotImplementedException ();
  164. }
  165. [MonoTODO]
  166. EventDescriptorCollection ICustomTypeDescriptor.GetEvents ()
  167. {
  168. throw new NotImplementedException ();
  169. }
  170. [MonoTODO]
  171. EventDescriptorCollection ICustomTypeDescriptor.GetEvents (Attribute[] attributes)
  172. {
  173. throw new NotImplementedException ();
  174. }
  175. [MonoTODO]
  176. PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties ()
  177. {
  178. throw new NotImplementedException ();
  179. }
  180. [MonoTODO]
  181. PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties (Attribute[] attributes)
  182. {
  183. throw new NotImplementedException ();
  184. }
  185. [MonoTODO]
  186. object ICustomTypeDescriptor.GetPropertyOwner (PropertyDescriptor pd)
  187. {
  188. throw new NotImplementedException ();
  189. }
  190. public bool IsDBNull (int i)
  191. {
  192. return GetValue (i) == null;
  193. }
  194. #endregion // Methods
  195. }
  196. }