DbDataReader.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. //
  2. // System.Data.Common.DbDataReader.cs
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2003
  8. //
  9. //
  10. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  11. //
  12. // Permission is hereby granted, free of charge, to any person obtaining
  13. // a copy of this software and associated documentation files (the
  14. // "Software"), to deal in the Software without restriction, including
  15. // without limitation the rights to use, copy, modify, merge, publish,
  16. // distribute, sublicense, and/or sell copies of the Software, and to
  17. // permit persons to whom the Software is furnished to do so, subject to
  18. // the following conditions:
  19. //
  20. // The above copyright notice and this permission notice shall be
  21. // included in all copies or substantial portions of the Software.
  22. //
  23. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  27. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  28. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  29. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. //
  31. #if NET_2_0 || TARGET_JVM
  32. using System.Collections;
  33. using System.Data;
  34. namespace System.Data.Common {
  35. public abstract class DbDataReader : MarshalByRefObject, IDataReader, IDataReader2, IDataRecord, IDataRecord2, IDisposable, IEnumerable
  36. {
  37. #region Constructors
  38. protected DbDataReader ()
  39. {
  40. }
  41. #endregion // Constructors
  42. #region Properties
  43. public abstract int Depth { get; }
  44. public abstract int FieldCount { get; }
  45. public abstract bool HasRows { get; }
  46. public abstract bool IsClosed { get; }
  47. public abstract object this [int index] { get; }
  48. public abstract object this [string name] { get; }
  49. public abstract int RecordsAffected { get; }
  50. #if NET_2_0
  51. public abstract int VisibleFieldCount { get; }
  52. #endif
  53. #endregion // Properties
  54. #region Methods
  55. public abstract void Close ();
  56. public abstract bool GetBoolean (int i);
  57. public abstract byte GetByte (int i);
  58. public abstract long GetBytes (int i, long fieldOffset, byte[] buffer, int bufferOffset, int length);
  59. public abstract char GetChar (int i);
  60. public abstract long GetChars (int i, long dataIndex, char[] buffer, int bufferIndex, int length);
  61. public virtual void Dispose ()
  62. {
  63. Dispose (true);
  64. }
  65. [MonoTODO]
  66. protected virtual void Dispose (bool disposing)
  67. {
  68. throw new NotImplementedException ();
  69. }
  70. #if NET_2_0
  71. [MonoTODO]
  72. public DbDataReader GetData (int i)
  73. {
  74. throw new NotImplementedException ();
  75. }
  76. #endif
  77. public abstract string GetDataTypeName (int i);
  78. public abstract DateTime GetDateTime (int i);
  79. public abstract decimal GetDecimal (int i);
  80. public abstract double GetDouble (int i);
  81. public abstract IEnumerator GetEnumerator ();
  82. public abstract Type GetFieldType (int i);
  83. public abstract float GetFloat (int i);
  84. public abstract Guid GetGuid (int i);
  85. public abstract short GetInt16 (int i);
  86. public abstract int GetInt32 (int i);
  87. public abstract long GetInt64 (int i);
  88. public abstract string GetName (int i);
  89. public abstract int GetOrdinal (string name);
  90. #if NET_2_0
  91. [MonoTODO]
  92. public virtual Type GetProviderSpecificFieldType (int i)
  93. {
  94. throw new NotImplementedException ();
  95. }
  96. [MonoTODO]
  97. public virtual object GetProviderSpecificValue (int i)
  98. {
  99. throw new NotImplementedException ();
  100. }
  101. [MonoTODO]
  102. public virtual int GetProviderSpecificValues (object[] values)
  103. {
  104. throw new NotImplementedException ();
  105. }
  106. [MonoTODO]
  107. public virtual int GetDbDataReader (int ordinal)
  108. {
  109. throw new NotImplementedException ();
  110. }
  111. #endif
  112. public abstract DataTable GetSchemaTable ();
  113. public abstract string GetString (int i);
  114. public abstract object GetValue (int i);
  115. public abstract int GetValues (object[] values);
  116. IDataReader IDataRecord.GetData (int i)
  117. {
  118. return ((IDataReader) this).GetData (i);
  119. }
  120. public abstract bool IsDBNull (int i);
  121. public abstract bool NextResult ();
  122. public abstract bool Read ();
  123. internal static DataTable GetSchemaTableTemplate ()
  124. {
  125. Type booleanType = Type.GetType ("System.Boolean");
  126. Type stringType = Type.GetType ("System.String");
  127. Type intType = Type.GetType ("System.Int32");
  128. Type typeType = Type.GetType ("System.Type");
  129. Type shortType = Type.GetType ("System.Int16");
  130. DataTable schemaTable = new DataTable ("SchemaTable");
  131. schemaTable.Columns.Add ("ColumnName", stringType);
  132. schemaTable.Columns.Add ("ColumnOrdinal", intType);
  133. schemaTable.Columns.Add ("ColumnSize", intType);
  134. schemaTable.Columns.Add ("NumericPrecision", shortType);
  135. schemaTable.Columns.Add ("NumericScale", shortType);
  136. schemaTable.Columns.Add ("IsUnique", booleanType);
  137. schemaTable.Columns.Add ("IsKey", booleanType);
  138. schemaTable.Columns.Add ("BaseServerName", stringType);
  139. schemaTable.Columns.Add ("BaseCatalogName", stringType);
  140. schemaTable.Columns.Add ("BaseColumnName", stringType);
  141. schemaTable.Columns.Add ("BaseSchemaName", stringType);
  142. schemaTable.Columns.Add ("BaseTableName", stringType);
  143. schemaTable.Columns.Add ("DataType", typeType);
  144. schemaTable.Columns.Add ("AllowDBNull", booleanType);
  145. schemaTable.Columns.Add ("ProviderType", intType);
  146. schemaTable.Columns.Add ("IsAliased", booleanType);
  147. schemaTable.Columns.Add ("IsExpression", booleanType);
  148. schemaTable.Columns.Add ("IsIdentity", booleanType);
  149. schemaTable.Columns.Add ("IsAutoIncrement", booleanType);
  150. schemaTable.Columns.Add ("IsRowVersion", booleanType);
  151. schemaTable.Columns.Add ("IsHidden", booleanType);
  152. schemaTable.Columns.Add ("IsLong", booleanType);
  153. schemaTable.Columns.Add ("IsReadOnly", booleanType);
  154. return schemaTable;
  155. }
  156. #endregion // Methods
  157. }
  158. }
  159. #endif