* RecordCache.cs: Reduce some extraneous nesting.
[mono.git] / mcs / class / System.Data / System.Data.Common / DbDataReader.cs
index 03a35de427c0058933a0f8aef994a705c333b988..7d046978a41ca66e73a53f66a106efa4ae174289 100644 (file)
 #if NET_2_0 || TARGET_JVM
 
 using System.Collections;
+using System.ComponentModel;
 using System.Data;
 
 namespace System.Data.Common {
-       public abstract class DbDataReader : MarshalByRefObject, IDataReader, IDataReader2, IDataRecord, IDataRecord2, IDisposable, IEnumerable
+       public abstract class DbDataReader : MarshalByRefObject, IDataReader, IDataRecord, IDisposable, IEnumerable
        {
                #region Constructors
 
@@ -55,10 +56,12 @@ namespace System.Data.Common {
                public abstract object this [int index] { get; }
                public abstract object this [string name] { get; }
                public abstract int RecordsAffected { get; }
+
 #if NET_2_0
-               public abstract int VisibleFieldCount { get; }
+               public virtual int VisibleFieldCount {
+                       get { return FieldCount; }
+               }
 #endif
-
                #endregion // Properties
 
                #region Methods
@@ -69,21 +72,23 @@ namespace System.Data.Common {
                public abstract long GetBytes (int i, long fieldOffset, byte[] buffer, int bufferOffset, int length);
                public abstract char GetChar (int i);
                public abstract long GetChars (int i, long dataIndex, char[] buffer, int bufferIndex, int length);
-               public virtual void Dispose ()
+
+               [EditorBrowsable (EditorBrowsableState.Never)]
+               public void Dispose ()
                {
                        Dispose (true); 
                }
                
-               [MonoTODO]
                protected virtual void Dispose (bool disposing)
                {
-                       throw new NotImplementedException ();
+                       if (disposing)
+                               Close ();
                }
 #if NET_2_0
-               [MonoTODO]
+               [EditorBrowsable (EditorBrowsableState.Never)]
                public DbDataReader GetData (int i)
                {
-                       throw new NotImplementedException ();
+                       return ((DbDataReader) this [i]);
                }
 #endif
 
@@ -91,7 +96,10 @@ namespace System.Data.Common {
                public abstract DateTime GetDateTime (int i);
                public abstract decimal GetDecimal (int i);
                public abstract double GetDouble (int i);
+
+               [EditorBrowsable (EditorBrowsableState.Never)]
                public abstract IEnumerator GetEnumerator ();
+
                public abstract Type GetFieldType (int i);
                public abstract float GetFloat (int i);
                public abstract Guid GetGuid (int i);
@@ -102,28 +110,27 @@ namespace System.Data.Common {
                public abstract int GetOrdinal (string name);
 
 #if NET_2_0
-               [MonoTODO]
+               [EditorBrowsable (EditorBrowsableState.Never)]
                public virtual Type GetProviderSpecificFieldType (int i)
                {
-                       throw new NotImplementedException ();
+                       return GetFieldType (i);
                }
 
-               [MonoTODO]
+               [EditorBrowsable (EditorBrowsableState.Never)]
                public virtual object GetProviderSpecificValue (int i)
                {
-                       throw new NotImplementedException ();
+                       return GetValue (i);
                }
 
-               [MonoTODO]
+               [EditorBrowsable (EditorBrowsableState.Never)]
                public virtual int GetProviderSpecificValues (object[] values)
                {
-                       throw new NotImplementedException ();
+                       return GetValues (values);
                }
        
-               [MonoTODO]
-               public virtual int GetDbDataReader (int ordinal)
+               protected virtual DbDataReader GetDbDataReader (int ordinal)
                {
-                       throw new NotImplementedException ();
+                       return ((DbDataReader) this [ordinal]);
                }
 #endif 
 
@@ -143,36 +150,36 @@ namespace System.Data.Common {
 
                 internal static DataTable GetSchemaTableTemplate ()
                {
-                       Type booleanType        = Type.GetType ("System.Boolean");
-                       Type stringType         = Type.GetType ("System.String");
-                       Type intType            = Type.GetType ("System.Int32");
-                       Type typeType           = Type.GetType ("System.Type");
-                       Type shortType          = Type.GetType ("System.Int16");
+                       Type booleanType = typeof (bool);
+                       Type stringType = typeof (string);
+                       Type intType = typeof (int);
+                       Type typeType = typeof (Type);
+                       Type shortType = typeof (short);
 
                        DataTable schemaTable = new DataTable ("SchemaTable");
-                       schemaTable.Columns.Add ("ColumnName",          stringType);
-                       schemaTable.Columns.Add ("ColumnOrdinal",       intType);
-                       schemaTable.Columns.Add ("ColumnSize",          intType);
-                       schemaTable.Columns.Add ("NumericPrecision",    shortType);
-                       schemaTable.Columns.Add ("NumericScale",        shortType);
-                       schemaTable.Columns.Add ("IsUnique",            booleanType);
-                       schemaTable.Columns.Add ("IsKey",               booleanType);
-                       schemaTable.Columns.Add ("BaseServerName",      stringType);
-                       schemaTable.Columns.Add ("BaseCatalogName",     stringType);
-                       schemaTable.Columns.Add ("BaseColumnName",      stringType);
-                       schemaTable.Columns.Add ("BaseSchemaName",      stringType);
-                       schemaTable.Columns.Add ("BaseTableName",       stringType);
-                       schemaTable.Columns.Add ("DataType",            typeType);
-                       schemaTable.Columns.Add ("AllowDBNull",         booleanType);
-                       schemaTable.Columns.Add ("ProviderType",        intType);
-                       schemaTable.Columns.Add ("IsAliased",           booleanType);
-                       schemaTable.Columns.Add ("IsExpression",        booleanType);
-                       schemaTable.Columns.Add ("IsIdentity",          booleanType);
-                       schemaTable.Columns.Add ("IsAutoIncrement",     booleanType);
-                       schemaTable.Columns.Add ("IsRowVersion",        booleanType);
-                       schemaTable.Columns.Add ("IsHidden",            booleanType);
-                       schemaTable.Columns.Add ("IsLong",              booleanType);
-                       schemaTable.Columns.Add ("IsReadOnly",          booleanType);
+                       schemaTable.Columns.Add ("ColumnName",       stringType);
+                       schemaTable.Columns.Add ("ColumnOrdinal",    intType);
+                       schemaTable.Columns.Add ("ColumnSize",       intType);
+                       schemaTable.Columns.Add ("NumericPrecision", shortType);
+                       schemaTable.Columns.Add ("NumericScale",     shortType);
+                       schemaTable.Columns.Add ("IsUnique",         booleanType);
+                       schemaTable.Columns.Add ("IsKey",            booleanType);
+                       schemaTable.Columns.Add ("BaseServerName",   stringType);
+                       schemaTable.Columns.Add ("BaseCatalogName",  stringType);
+                       schemaTable.Columns.Add ("BaseColumnName",   stringType);
+                       schemaTable.Columns.Add ("BaseSchemaName",   stringType);
+                       schemaTable.Columns.Add ("BaseTableName",    stringType);
+                       schemaTable.Columns.Add ("DataType",         typeType);
+                       schemaTable.Columns.Add ("AllowDBNull",      booleanType);
+                       schemaTable.Columns.Add ("ProviderType",     intType);
+                       schemaTable.Columns.Add ("IsAliased",        booleanType);
+                       schemaTable.Columns.Add ("IsExpression",     booleanType);
+                       schemaTable.Columns.Add ("IsIdentity",       booleanType);
+                       schemaTable.Columns.Add ("IsAutoIncrement",  booleanType);
+                       schemaTable.Columns.Add ("IsRowVersion",     booleanType);
+                       schemaTable.Columns.Add ("IsHidden",         booleanType);
+                       schemaTable.Columns.Add ("IsLong",           booleanType);
+                       schemaTable.Columns.Add ("IsReadOnly",       booleanType);
 
                        return schemaTable;
                }