Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -30,7 +30,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
namespace System.Data.Common {
public enum CatalogLocation
@@ -40,4 +39,3 @@ namespace System.Data.Common {
}
}
#endif

View File

@@ -43,9 +43,6 @@ namespace System.Data.Common
/// Represents a set of data commands and a database connection that are used to fill the DataSet and update the data source.
/// </summary>
public
#if ONLY_1_1
abstract
#endif
class DataAdapter : Component, IDataAdapter
{
#region Fields
@@ -58,11 +55,9 @@ namespace System.Data.Common
private const string DefaultSourceTableName = "Table";
private const string DefaultSourceColumnName = "Column";
#if NET_2_0
private bool acceptChangesDuringUpdate;
private LoadOption fillLoadOption;
private bool returnProviderSpecificTypes;
#endif
#endregion
#region Constructors
@@ -74,11 +69,9 @@ namespace System.Data.Common
missingMappingAction = MissingMappingAction.Passthrough;
missingSchemaAction = MissingSchemaAction.Add;
tableMappings = new DataTableMappingCollection ();
#if NET_2_0
acceptChangesDuringUpdate = true;
fillLoadOption = LoadOption.OverwriteChanges;
returnProviderSpecificTypes = false;
#endif
}
protected DataAdapter (DataAdapter from)
@@ -91,11 +84,9 @@ namespace System.Data.Common
if (from.tableMappings != null)
foreach (ICloneable cloneable in from.TableMappings)
TableMappings.Add (cloneable.Clone ());
#if NET_2_0
acceptChangesDuringUpdate = from.AcceptChangesDuringUpdate;
fillLoadOption = from.FillLoadOption;
returnProviderSpecificTypes = from.ReturnProviderSpecificTypes;
#endif
}
#endregion
@@ -103,34 +94,25 @@ namespace System.Data.Common
#region Properties
[DataCategory ("Fill")]
#if !NET_2_0
[DataSysDescription ("Whether or not Fill will call DataRow.AcceptChanges.")]
#endif
[DefaultValue (true)]
public bool AcceptChangesDuringFill {
get { return acceptChangesDuringFill; }
set { acceptChangesDuringFill = value; }
}
#if NET_2_0
[DefaultValue (true)]
public bool AcceptChangesDuringUpdate {
get { return acceptChangesDuringUpdate; }
set { acceptChangesDuringUpdate = value; }
}
#endif
[DataCategory ("Update")]
#if !NET_2_0
[DataSysDescription ("Whether or not to continue to the next DataRow when the Update events, RowUpdating and RowUpdated, Status is UpdateStatus.ErrorsOccurred.")]
#endif
[DefaultValue (false)]
public bool ContinueUpdateOnError {
get { return continueUpdateOnError; }
set { continueUpdateOnError = value; }
}
#if NET_2_0
[RefreshProperties (RefreshProperties.All)]
public LoadOption FillLoadOption {
get { return fillLoadOption; }
@@ -139,16 +121,12 @@ namespace System.Data.Common
fillLoadOption = value;
}
}
#endif
ITableMappingCollection IDataAdapter.TableMappings {
get { return TableMappings; }
}
[DataCategory ("Mapping")]
#if !NET_2_0
[DataSysDescription ("The action taken when a table or column in the TableMappings is missing.")]
#endif
[DefaultValue (MissingMappingAction.Passthrough)]
public MissingMappingAction MissingMappingAction {
get { return missingMappingAction; }
@@ -159,9 +137,6 @@ namespace System.Data.Common
}
[DataCategory ("Mapping")]
#if !NET_2_0
[DataSysDescription ("The action taken when a table or column in the DataSet is missing.")]
#endif
[DefaultValue (MissingSchemaAction.Add)]
public MissingSchemaAction MissingSchemaAction {
get { return missingSchemaAction; }
@@ -171,18 +146,13 @@ namespace System.Data.Common
}
}
#if NET_2_0
[DefaultValue (false)]
public virtual bool ReturnProviderSpecificTypes {
get { return returnProviderSpecificTypes; }
set { returnProviderSpecificTypes = value; }
}
#endif
[DataCategory ("Mapping")]
#if !NET_2_0
[DataSysDescription ("How to map source table to DataSet table.")]
#endif
[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
public DataTableMappingCollection TableMappings {
get { return tableMappings; }
@@ -192,9 +162,7 @@ namespace System.Data.Common
#region Events
#if NET_2_0
public event FillErrorEventHandler FillError;
#endif
#endregion
@@ -312,7 +280,7 @@ namespace System.Data.Common
//FIXME : The sourcetable name shud get passed as a parameter..
int index = dtMapping.IndexOfDataSetTable (table.TableName);
string srcTable = (index != -1 ? dtMapping[index].SourceTable : table.TableName);
tableMapping = DataTableMappingCollection.GetTableMappingBySchemaAction (dtMapping, srcTable, table.TableName, missingMapAction);
tableMapping = DataTableMappingCollection.GetTableMappingBySchemaAction (dtMapping, ADP.IsEmpty (srcTable) ? " " : srcTable, table.TableName, missingMapAction);
if (tableMapping != null) {
table.TableName = tableMapping.DataSetTable;
// check to see if the column mapping exists
@@ -468,9 +436,7 @@ namespace System.Data.Common
internal virtual void OnFillErrorInternal (FillErrorEventArgs value)
{
#if NET_2_0
OnFillError (value);
#endif
}
internal FillErrorEventArgs CreateFillErrorEvent (DataTable dataTable, object[] values, Exception e)
@@ -544,7 +510,6 @@ namespace System.Data.Common
return count;
}
#if NET_2_0
public virtual int Fill (DataSet dataSet)
{
throw new NotSupportedException();
@@ -645,12 +610,6 @@ namespace System.Data.Common
{
throw new NotImplementedException ();
}
#else
public abstract int Fill (DataSet dataSet);
public abstract DataTable[] FillSchema (DataSet dataSet, SchemaType schemaType);
public abstract IDataParameter[] GetFillParameters ();
public abstract int Update (DataSet dataSet);
#endif
#endregion

View File

@@ -1,131 +0,0 @@
//
// System.Data.Common.DataColumnMapping.cs
//
// Authors:
// Rodrigo Moya (rodrigo@ximian.com)
// Tim Coleman (tim@timcoleman.com)
//
// (C) Ximian, Inc
// Copyright (C) Tim Coleman, 2002-2003
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.Data;
namespace System.Data.Common {
#if NET_2_0
[TypeConverterAttribute ("System.Data.Common.DataColumnMapping+DataColumnMappingConverter, " + Consts.AssemblySystem_Data)]
#else
[TypeConverterAttribute (typeof (DataColumnMappingConverter))]
#endif
public sealed class DataColumnMapping : MarshalByRefObject, IColumnMapping, ICloneable
{
#region Fields
string sourceColumn;
string dataSetColumn;
#endregion // Fields
#region Constructors
public DataColumnMapping ()
{
sourceColumn = String.Empty;
dataSetColumn = String.Empty;
}
public DataColumnMapping (string sourceColumn, string dataSetColumn)
{
this.sourceColumn = sourceColumn;
this.dataSetColumn = dataSetColumn;
}
#endregion // Constructors
#region Properties
#if ONLY_1_1
[DataSysDescription ("DataColumn.ColumnName")]
#endif
[DefaultValue ("")]
public string DataSetColumn {
get { return dataSetColumn; }
set { dataSetColumn = value; }
}
#if !NET_2_0
[DataSysDescription ("Source column name - case sensitive.")]
#endif
[DefaultValue ("")]
public string SourceColumn {
get { return sourceColumn; }
set { sourceColumn = value; }
}
#endregion // Properties
#region Methods
[EditorBrowsable (EditorBrowsableState.Advanced)]
public DataColumn GetDataColumnBySchemaAction (DataTable dataTable, Type dataType, MissingSchemaAction schemaAction)
{
if (dataTable.Columns.Contains (dataSetColumn))
return dataTable.Columns [dataSetColumn];
if (schemaAction == MissingSchemaAction.Ignore)
return null;
if (schemaAction == MissingSchemaAction.Error)
throw new InvalidOperationException (String.Format ("Missing the DataColumn '{0}' in the DataTable '{1}' for the SourceColumn '{2}'", DataSetColumn, dataTable.TableName, SourceColumn));
return new DataColumn (dataSetColumn, dataType);
}
#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Advanced)]
public static DataColumn GetDataColumnBySchemaAction (string sourceColumn, string dataSetColumn, DataTable dataTable, Type dataType, MissingSchemaAction schemaAction)
{
if (dataTable.Columns.Contains (dataSetColumn))
return dataTable.Columns [dataSetColumn];
if (schemaAction == MissingSchemaAction.Ignore)
return null;
if (schemaAction == MissingSchemaAction.Error)
throw new InvalidOperationException (String.Format ("Missing the DataColumn '{0}' in the DataTable '{1}' for the SourceColumn '{2}'", dataSetColumn, dataTable.TableName, sourceColumn));
return new DataColumn (dataSetColumn, dataType);
}
#endif
object ICloneable.Clone ()
{
return new DataColumnMapping (SourceColumn, DataSetColumn);
}
public override string ToString ()
{
return SourceColumn;
}
#endregion // Methods
}
}

View File

@@ -1,338 +0,0 @@
//
// System.Data.Common.DataColumnMappingCollection
//
// Authors:
// Rodrigo Moya (rodrigo@ximian.com)
// Tim Coleman (tim@timcoleman.com)
//
// (C) Ximian, Inc
// Copyright (C) Tim Coleman, 2002-2003
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
namespace System.Data.Common
{
public sealed class DataColumnMappingCollection : MarshalByRefObject, IColumnMappingCollection , IList, ICollection, IEnumerable
{
#region Fields
readonly ArrayList list;
readonly Hashtable sourceColumns;
readonly Hashtable dataSetColumns;
#endregion // Fields
#region Constructors
public DataColumnMappingCollection ()
{
list = new ArrayList ();
sourceColumns = new Hashtable ();
dataSetColumns = new Hashtable ();
}
#endregion // Constructors
#region Properties
[Browsable (false)]
#if !NET_2_0
[DataSysDescription ("The number of items in the collection")]
#endif
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public int Count {
get { return list.Count; }
}
[Browsable (false)]
#if !NET_2_0
[DataSysDescription ("The specified DataColumnMapping object.")]
#endif
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public DataColumnMapping this [int index] {
get { return (DataColumnMapping)(list[index]); }
set {
DataColumnMapping mapping = (DataColumnMapping)(list[index]);
sourceColumns[mapping] = value;
dataSetColumns[mapping] = value;
list[index] = value;
}
}
[Browsable (false)]
#if !NET_2_0
[DataSysDescription ("The specified DataColumnMapping object.")]
#endif
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public DataColumnMapping this [string sourceColumn] {
get {
if (!Contains(sourceColumn))
throw new IndexOutOfRangeException("DataColumnMappingCollection doesn't contain DataColumnMapping with SourceColumn '" + sourceColumn + "'.");
return (DataColumnMapping) sourceColumns [sourceColumn];
}
set {
this [list.IndexOf (sourceColumns [sourceColumn])] = value;
}
}
object ICollection.SyncRoot {
get { return list.SyncRoot; }
}
bool ICollection.IsSynchronized {
get { return list.IsSynchronized; }
}
object IColumnMappingCollection.this [string index] {
get { return this [index]; }
set {
if (!(value is DataColumnMapping))
throw new ArgumentException ();
this [index] = (DataColumnMapping) value;
}
}
object IList.this [int index] {
get { return this [index]; }
set {
if (!(value is DataColumnMapping))
throw new ArgumentException ();
this [index] = (DataColumnMapping) value;
}
}
bool IList.IsReadOnly {
get { return false; }
}
bool IList.IsFixedSize {
get { return false; }
}
#endregion // Properties
#region Methods
public int Add (object value)
{
if (!(value is DataColumnMapping))
throw new InvalidCastException ();
list.Add (value);
sourceColumns [((DataColumnMapping) value).SourceColumn] = value;
dataSetColumns [((DataColumnMapping )value).DataSetColumn] = value;
return list.IndexOf (value);
}
public DataColumnMapping Add (string sourceColumn, string dataSetColumn)
{
DataColumnMapping mapping = new DataColumnMapping (sourceColumn, dataSetColumn);
Add (mapping);
return mapping;
}
#if NET_2_0
public void AddRange (Array values)
{
for (int i = 0; i < values.Length; ++i)
Add (values.GetValue (i));
}
#endif
public void AddRange (DataColumnMapping[] values)
{
foreach (DataColumnMapping mapping in values)
Add (mapping);
}
public void Clear ()
{
list.Clear ();
}
public bool Contains (object value)
{
if (!(value is DataColumnMapping))
throw new InvalidCastException("Object is not of type DataColumnMapping");
return (list.Contains (value));
}
public bool Contains (string value)
{
return (sourceColumns.Contains (value));
}
public void CopyTo (Array array, int index)
{
list.CopyTo (array,index);
}
#if NET_2_0
public void CopyTo (DataColumnMapping [] array, int index)
{
list.CopyTo (array, index);
}
#endif
public DataColumnMapping GetByDataSetColumn (string value)
{
// this should work case-insenstive.
if (!(dataSetColumns [value] == null))
return (DataColumnMapping) (dataSetColumns [value]);
else {
string lowcasevalue = value.ToLower ();
object [] keyarray = new object [dataSetColumns.Count];
dataSetColumns.Keys.CopyTo (keyarray, 0);
for (int i = 0; i < keyarray.Length; i++) {
string temp = (string) keyarray [i];
if (lowcasevalue.Equals (temp.ToLower ()))
return (DataColumnMapping) (dataSetColumns [keyarray [i]]);
}
return null;
}
}
[EditorBrowsable (EditorBrowsableState.Advanced)]
public static DataColumnMapping GetColumnMappingBySchemaAction (DataColumnMappingCollection columnMappings, string sourceColumn, MissingMappingAction mappingAction)
{
if (columnMappings.Contains (sourceColumn))
return columnMappings[sourceColumn];
if (mappingAction == MissingMappingAction.Ignore)
return null;
if (mappingAction == MissingMappingAction.Error)
throw new InvalidOperationException (String.Format ("Missing SourceColumn mapping for '{0}'", sourceColumn));
return new DataColumnMapping (sourceColumn, sourceColumn);
}
#if NET_2_0
[MonoTODO]
[EditorBrowsable (EditorBrowsableState.Advanced)]
public static DataColumn GetDataColumn (DataColumnMappingCollection columnMappings, string sourceColumn, Type dataType, DataTable dataTable, MissingMappingAction mappingAction, MissingSchemaAction schemaAction)
{
throw new NotImplementedException ();
}
#endif
public IEnumerator GetEnumerator ()
{
return list.GetEnumerator ();
}
IColumnMapping IColumnMappingCollection.Add (string sourceColumnName, string dataSetColumnName)
{
return Add (sourceColumnName, dataSetColumnName);
}
IColumnMapping IColumnMappingCollection.GetByDataSetColumn (string dataSetColumnName)
{
return GetByDataSetColumn (dataSetColumnName);
}
public int IndexOf (object value)
{
return list.IndexOf (value);
}
public int IndexOf (string sourceColumn)
{
return list.IndexOf (sourceColumns [sourceColumn]);
}
public int IndexOfDataSetColumn (string dataSetColumn)
{
// this should work case-insensitive
if (!(dataSetColumns [dataSetColumn] == null))
return list.IndexOf (dataSetColumns [dataSetColumn]);
else {
string lowcasevalue = dataSetColumn.ToLower ();
object [] keyarray = new object[dataSetColumns.Count];
dataSetColumns.Keys.CopyTo (keyarray,0);
for (int i = 0; i < keyarray.Length; i++) {
string temp = (string) keyarray [i];
if (lowcasevalue.Equals (temp.ToLower ()))
return list.IndexOf (dataSetColumns [keyarray [i]]);
}
return -1;
}
}
public void Insert (int index, object value)
{
list.Insert (index, value);
sourceColumns [((DataColumnMapping) value).SourceColumn] = value;
dataSetColumns [((DataColumnMapping) value).DataSetColumn] = value;
}
#if NET_2_0
public void Insert (int index, DataColumnMapping value)
{
list.Insert (index, value);
sourceColumns [value.SourceColumn] = value;
dataSetColumns [value.DataSetColumn] = value;
}
#endif
public void Remove (object value)
{
int index = list.IndexOf (value);
sourceColumns.Remove (((DataColumnMapping) value).SourceColumn);
dataSetColumns.Remove (((DataColumnMapping) value).DataSetColumn);
if (index < 0 || index >=list.Count)
throw new ArgumentException("There is no such element in collection.");
list.Remove (value);
}
#if NET_2_0
public void Remove (DataColumnMapping value)
{
int index = list.IndexOf (value);
sourceColumns.Remove (value.SourceColumn);
dataSetColumns.Remove (value.DataSetColumn);
if ( index < 0 || index >=list.Count)
throw new ArgumentException("There is no such element in collection.");
list.Remove (value);
}
#endif
public void RemoveAt (int index)
{
if (index < 0 || index >=list.Count)
throw new IndexOutOfRangeException("There is no element in collection.");
Remove (list [index]);
}
public void RemoveAt (string sourceColumn)
{
RemoveAt (list.IndexOf (sourceColumns [sourceColumn]));
}
#endregion // Methods
}
}

View File

@@ -1,59 +0,0 @@
//
// System.Data.Common.DataColumnMappingConverter.cs
//
// Author:
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2004 Andreas Nahr
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Globalization;
using System.ComponentModel;
namespace System.Data.Common
{
internal sealed class DataColumnMappingConverter : ExpandableObjectConverter
{
[MonoTODO]
public DataColumnMappingConverter ()
{
throw new NotImplementedException ();
}
[MonoTODO]
public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
throw new NotImplementedException ();
}
[MonoTODO]
public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
{
throw new NotImplementedException ();
}
}
}

View File

@@ -1,159 +0,0 @@
//
// System.Data.Common.DataTableMapping.cs
//
// Authors:
// Rodrigo Moya (rodrigo@ximian.com)
// Tim Coleman (tim@timcoleman.com)
//
// (C) Ximian, Inc
// Copyright (C) Tim Coleman, 2002-2003
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.Data;
namespace System.Data.Common {
#if NET_2_0
[TypeConverterAttribute ("System.Data.Common.DataTableMapping+DataTableMappingConverter, " + Consts.AssemblySystem_Data)]
#else
[TypeConverterAttribute (typeof (DataTableMappingConverter))]
#endif
public sealed class DataTableMapping : MarshalByRefObject, ITableMapping, ICloneable
{
#region Fields
string sourceTable;
string dataSetTable;
DataColumnMappingCollection columnMappings;
#endregion // Fields
#region Constructors
public DataTableMapping ()
{
dataSetTable = String.Empty;
sourceTable = String.Empty;
columnMappings = new DataColumnMappingCollection ();
}
public DataTableMapping (string sourceTable, string dataSetTable)
: this ()
{
this.sourceTable = sourceTable;
this.dataSetTable = dataSetTable;
}
public DataTableMapping (string sourceTable, string dataSetTable, DataColumnMapping[] columnMappings)
: this (sourceTable, dataSetTable)
{
this.columnMappings.AddRange (columnMappings);
}
#endregion // Constructors
#region Properties
#if !NET_2_0
[DataSysDescription ("Individual columns mappings when this table mapping is matched.")]
#endif
[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
public DataColumnMappingCollection ColumnMappings {
get { return columnMappings; }
}
#if !NET_2_0
[DataSysDescription ("DataTable.TableName")]
#endif
[DefaultValue ("")]
public string DataSetTable {
get { return dataSetTable; }
set { dataSetTable = value; }
}
IColumnMappingCollection ITableMapping.ColumnMappings {
get { return ColumnMappings; }
}
#if !NET_2_0
[DataSysDescription ("The DataTableMapping source table name. This name is case sensitive.")]
#endif
[DefaultValue ("")]
public string SourceTable {
get { return sourceTable; }
set { sourceTable = value; }
}
#endregion // Properties
#region Methods
[EditorBrowsable (EditorBrowsableState.Advanced)]
public DataColumnMapping GetColumnMappingBySchemaAction (string sourceColumn, MissingMappingAction mappingAction)
{
return DataColumnMappingCollection.GetColumnMappingBySchemaAction (columnMappings, sourceColumn, mappingAction);
}
#if NET_2_0
[MonoTODO]
[EditorBrowsable (EditorBrowsableState.Advanced)]
public DataColumn GetDataColumn (string sourceColumn,
Type dataType,
DataTable dataTable,
MissingMappingAction mappingAction,
MissingSchemaAction schemaAction)
{
throw new NotImplementedException ();
}
#endif
[EditorBrowsable (EditorBrowsableState.Advanced)]
public DataTable GetDataTableBySchemaAction (DataSet dataSet, MissingSchemaAction schemaAction)
{
if (dataSet.Tables.Contains (DataSetTable))
return dataSet.Tables [DataSetTable];
if (schemaAction == MissingSchemaAction.Ignore)
return null;
if (schemaAction == MissingSchemaAction.Error)
throw new InvalidOperationException (String.Format ("Missing the '{0} DataTable for the '{1}' SourceTable", DataSetTable, SourceTable));
return new DataTable (DataSetTable);
}
object ICloneable.Clone ()
{
DataColumnMapping [] arr = new DataColumnMapping [columnMappings.Count];
columnMappings.CopyTo (arr, 0);
return new DataTableMapping (SourceTable, DataSetTable, arr);
}
public override string ToString ()
{
return SourceTable;
}
#endregion // Methods
}
}

View File

@@ -1,326 +0,0 @@
//
// System.Data.Common.DataTableMappingCollection.cs
//
// Author:
// Rodrigo Moya (rodrigo@ximian.com)
// Tim Coleman (tim@timcoleman.com)
//
// (C) Ximian, Inc
// Copyright (C) Tim Coleman, 2002-2003
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.ComponentModel;
namespace System.Data.Common
{
[ListBindable (false)]
[EditorAttribute ("Microsoft.VSDesigner.Data.Design.DataTableMappingCollectionEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
public sealed class DataTableMappingCollection : MarshalByRefObject, ITableMappingCollection, IList, ICollection, IEnumerable
{
#region Fields
ArrayList mappings;
Hashtable sourceTables;
Hashtable dataSetTables;
#endregion
#region Constructors
public DataTableMappingCollection()
{
mappings = new ArrayList ();
sourceTables = new Hashtable ();
dataSetTables = new Hashtable ();
}
#endregion // Constructors
#region Properties
[Browsable (false)]
#if !NET_2_0
[DataSysDescription ("The number of items in the collection")]
#endif
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public int Count {
get { return mappings.Count; }
}
[Browsable (false)]
#if !NET_2_0
[DataSysDescription ("The specified DataTableMapping object")]
#endif
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public DataTableMapping this [int index] {
get { return (DataTableMapping)(mappings[index]); }
set {
DataTableMapping mapping = (DataTableMapping) mappings[index];
sourceTables [mapping.SourceTable] = value;
dataSetTables [mapping.DataSetTable] = value;
mappings [index] = value;
}
}
[Browsable (false)]
#if !NET_2_0
[DataSysDescription ("The specified DataTableMapping object")]
#endif
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public DataTableMapping this [string sourceTable] {
get { return (DataTableMapping) sourceTables[sourceTable]; }
set { this [mappings.IndexOf (sourceTables[sourceTable])] = value; }
}
object IList.this [int index] {
get { return (object)(this[index]); }
set {
if (!(value is DataTableMapping))
throw new ArgumentException ();
this[index] = (DataTableMapping)value;
}
}
bool ICollection.IsSynchronized {
get { return mappings.IsSynchronized; }
}
object ICollection.SyncRoot {
get { return mappings.SyncRoot; }
}
bool IList.IsFixedSize {
get { return false; }
}
bool IList.IsReadOnly {
get { return false; }
}
object ITableMappingCollection.this [string index] {
get { return this [index]; }
set {
if (!(value is DataTableMapping))
throw new ArgumentException ();
this [index] = (DataTableMapping) value;
}
}
#endregion // Properties
#region Methods
public int Add (object value)
{
if (!(value is System.Data.Common.DataTableMapping))
throw new InvalidCastException ("The object passed in was not a DataTableMapping object.");
sourceTables [((DataTableMapping) value).SourceTable] = value;
dataSetTables [((DataTableMapping) value).DataSetTable] = value;
return mappings.Add (value);
}
public DataTableMapping Add (string sourceTable, string dataSetTable)
{
DataTableMapping mapping = new DataTableMapping (sourceTable, dataSetTable);
Add (mapping);
return mapping;
}
#if NET_2_0
public void AddRange (Array values)
{
for (int i = 0; i < values.Length; ++i)
Add (values.GetValue (i));
}
#endif
public void AddRange (DataTableMapping[] values)
{
foreach (DataTableMapping dataTableMapping in values)
this.Add (dataTableMapping);
}
public void Clear ()
{
sourceTables.Clear ();
dataSetTables.Clear ();
mappings.Clear ();
}
public bool Contains (object value)
{
return mappings.Contains (value);
}
public bool Contains (string value)
{
return sourceTables.Contains (value);
}
public void CopyTo (Array array, int index)
{
mappings.CopyTo (array, index);
}
#if NET_2_0
public void CopyTo (DataTableMapping[] array, int index)
{
mappings.CopyTo (array, index);
}
#endif
public DataTableMapping GetByDataSetTable (string dataSetTable)
{
// this should work case-insenstive.
if (!(dataSetTables[dataSetTable] == null))
return (DataTableMapping) (dataSetTables [dataSetTable]);
else {
string lowcasevalue = dataSetTable.ToLower ();
object [] keyarray = new object [dataSetTables.Count];
dataSetTables.Keys.CopyTo (keyarray, 0);
for (int i=0; i<keyarray.Length; i++) {
string temp = (string) keyarray [i];
if (lowcasevalue.Equals (temp.ToLower ()))
return (DataTableMapping) (dataSetTables [keyarray [i]]);
}
return null;
}
}
[EditorBrowsable (EditorBrowsableState.Advanced)]
public static DataTableMapping GetTableMappingBySchemaAction (DataTableMappingCollection tableMappings, string sourceTable, string dataSetTable, MissingMappingAction mappingAction)
{
if (tableMappings.Contains (sourceTable))
return tableMappings[sourceTable];
if (mappingAction == MissingMappingAction.Error)
throw new InvalidOperationException (String.Format ("Missing source table mapping: '{0}'",
sourceTable));
if (mappingAction == MissingMappingAction.Ignore)
return null;
return new DataTableMapping (sourceTable, dataSetTable);
}
public IEnumerator GetEnumerator ()
{
return mappings.GetEnumerator ();
}
public int IndexOf (object value)
{
return mappings.IndexOf (value);
}
public int IndexOf (string sourceTable)
{
return IndexOf (sourceTables[sourceTable]);
}
public int IndexOfDataSetTable (string dataSetTable)
{
// this should work case-insensitive
if (!(dataSetTables[dataSetTable] == null))
return IndexOf ((DataTableMapping)(dataSetTables[dataSetTable]));
else {
string lowcasevalue = dataSetTable.ToLower();
object [] keyarray = new object[dataSetTables.Count];
dataSetTables.Keys.CopyTo(keyarray,0);
for (int i=0; i<keyarray.Length; i++) {
string temp = (string) keyarray[i];
if (lowcasevalue.Equals(temp.ToLower()))
return IndexOf ((DataTableMapping)(dataSetTables[keyarray[i]]));
}
return -1;
}
}
public void Insert (int index, object value)
{
mappings.Insert (index, value);
sourceTables [((DataTableMapping) value).SourceTable] = value;
dataSetTables [((DataTableMapping) value).DataSetTable] = value;
}
#if NET_2_0
public void Insert (int index, DataTableMapping value)
{
mappings.Insert (index, value);
sourceTables [value.SourceTable] = value;
dataSetTables [value.DataSetTable] = value;
}
#endif
ITableMapping ITableMappingCollection.Add (string sourceTableName, string dataSetTableName)
{
ITableMapping tableMapping = new DataTableMapping (sourceTableName, dataSetTableName);
Add (tableMapping);
return tableMapping;
}
ITableMapping ITableMappingCollection.GetByDataSetTable (string dataSetTableName)
{
return this [mappings.IndexOf (dataSetTables [dataSetTableName])];
}
public void Remove (object value)
{
if (!(value is DataTableMapping))
throw new InvalidCastException ();
int index = mappings.IndexOf (value);
if (index < 0 || index >= mappings.Count)
throw new ArgumentException("There is no such element in collection.");
mappings.Remove ((DataTableMapping) value);
}
#if NET_2_0
public void Remove (DataTableMapping value)
{
int index = mappings.IndexOf (value);
if (index < 0 || index >= mappings.Count)
throw new ArgumentException("There is no such element in collection.");
mappings.Remove ((DataTableMapping) value);
}
#endif
public void RemoveAt (int index)
{
if (index < 0 || index >= mappings.Count)
throw new IndexOutOfRangeException("There is no element in collection.");
mappings.RemoveAt (index);
}
public void RemoveAt (string sourceTable)
{
RemoveAt (mappings.IndexOf (sourceTables[sourceTable]));
}
#endregion // Methods
}
}

View File

@@ -1,59 +0,0 @@
//
// System.Data.Common.DataTableMappingConverter.cs
//
// Author:
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2004 Andreas Nahr
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Globalization;
using System.ComponentModel;
namespace System.Data.Common
{
internal sealed class DataTableMappingConverter : ExpandableObjectConverter
{
[MonoTODO]
public DataTableMappingConverter ()
{
throw new NotImplementedException ();
}
[MonoTODO]
public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
throw new NotImplementedException ();
}
[MonoTODO]
public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
{
throw new NotImplementedException ();
}
}
}

View File

@@ -33,10 +33,8 @@
using System.ComponentModel;
using System.Data;
#if NET_4_5
using System.Threading;
using System.Threading.Tasks;
#endif
namespace System.Data.Common {
public abstract class DbCommand : Component, IDbCommand, IDisposable
@@ -150,7 +148,6 @@ namespace System.Data.Common {
public abstract void Prepare ();
#if NET_4_5
protected virtual Task<DbDataReader> ExecuteDbDataReaderAsync (CommandBehavior behavior, CancellationToken cancellationToken)
{
if (cancellationToken.IsCancellationRequested) {
@@ -236,7 +233,6 @@ namespace System.Data.Common {
}
}
#endif
#endregion // Methods

View File

@@ -30,7 +30,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System.ComponentModel;
using System.Data;
@@ -695,4 +694,3 @@ namespace System.Data.Common {
}
}
#endif

View File

@@ -32,14 +32,10 @@
using System.ComponentModel;
using System.Data;
#if NET_2_0
using System.Transactions;
#endif
#if NET_4_5
using System.Threading;
using System.Threading.Tasks;
#endif
namespace System.Data.Common {
public abstract class DbConnection : Component, IDbConnection, IDisposable
@@ -97,14 +93,11 @@ namespace System.Data.Common {
protected abstract DbCommand CreateDbCommand ();
#if NET_2_0
public virtual void EnlistTransaction (Transaction transaction)
{
throw new NotSupportedException ();
}
#endif
#if NET_2_0
static class DataTypes
{
static readonly ColumnInfo [] columns = {
@@ -723,7 +716,6 @@ namespace System.Data.Common {
return null;
}
}
#endif
IDbTransaction IDbConnection.BeginTransaction ()
{
@@ -748,7 +740,6 @@ namespace System.Data.Common {
StateChange (this, stateChange);
}
#if NET_4_5
public Task OpenAsync ()
{
return OpenAsync (CancellationToken.None);
@@ -767,7 +758,6 @@ namespace System.Data.Common {
return TaskHelper.CreateExceptionTask (e);
}
}
#endif
#endregion // Methods

View File

@@ -1,257 +0,0 @@
//
// System.Data.Common.DbConnectionOptions
// adapted from older (pre beta1) DbConnectionString
//
// Authors:
// Tim Coleman (tim@timcoleman.com)
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) Tim Coleman, 2003
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System.Collections;
using System.Collections.Specialized;
using System.Security;
using System.Text;
namespace System.Data.Common {
internal class DbConnectionOptions {
#region Fields
internal NameValueCollection options;
internal string normalizedConnectionString;
#endregion // Fields
#region Constructors
internal DbConnectionOptions ()
{
}
protected internal DbConnectionOptions (DbConnectionOptions connectionOptions)
{
options = connectionOptions.options;
}
public DbConnectionOptions (string connectionString)
{
options = new NameValueCollection ();
ParseConnectionString (connectionString);
}
[MonoTODO]
public DbConnectionOptions (string connectionString, Hashtable synonyms, bool useFirstKeyValuePair)
: this (connectionString)
{
}
#endregion // Constructors
#region Properties
[MonoTODO]
public bool IsEmpty {
get { throw new NotImplementedException (); }
}
public string this [string keyword] {
get { return options [keyword]; }
}
public ICollection Keys {
get { return options.Keys; }
}
#endregion // Properties
#region Methods
[MonoTODO]
protected void BuildConnectionString (StringBuilder builder, string[] withoutOptions, string insertValue)
{
throw new NotImplementedException ();
}
public bool ContainsKey (string keyword)
{
return (options.Get (keyword) != null);
}
public bool ConvertValueToBoolean (string keyname, bool defaultvalue)
{
if (ContainsKey (keyname))
return Boolean.Parse (this [keyname].Trim ());
return defaultvalue;
}
public int ConvertValueToInt32 (string keyname, int defaultvalue)
{
if (ContainsKey (keyname))
return Int32.Parse (this [keyname].Trim ());
return defaultvalue;
}
[MonoTODO]
public bool ConvertValueToIntegratedSecurity ()
{
throw new NotImplementedException ();
}
public string ConvertValueToString (string keyname, string defaultValue)
{
if (ContainsKey (keyname))
return this [keyname];
return defaultValue;
}
[MonoTODO]
protected internal virtual PermissionSet CreatePermissionSet ()
{
throw new NotImplementedException ();
}
[MonoTODO]
protected internal virtual string Expand ()
{
throw new NotImplementedException ();
}
[MonoTODO]
public static string RemoveKeyValuePairs (string connectionString, string[] keynames)
{
throw new NotImplementedException ();
}
[MonoTODO]
public string UsersConnectionString (bool hisPasswordPwd)
{
throw new NotImplementedException ();
}
internal void ParseConnectionString (string connectionString)
{
if (connectionString.Length == 0)
return;
connectionString += ";";
bool inQuote = false;
bool inDQuote = false;
bool inName = true;
string name = String.Empty;
string value = String.Empty;
StringBuilder sb = new StringBuilder ();
for (int i = 0; i < connectionString.Length; i += 1) {
char c = connectionString [i];
char peek;
if (i == connectionString.Length - 1)
peek = '\0';
else
peek = connectionString [i + 1];
switch (c) {
case '\'':
if (inDQuote)
sb.Append (c);
else if (peek.Equals (c)) {
sb.Append (c);
i += 1;
}
else
inQuote = !inQuote;
break;
case '"':
if (inQuote)
sb.Append (c);
else if (peek.Equals (c)) {
sb.Append (c);
i += 1;
}
else
inDQuote = !inDQuote;
break;
case ';':
if (inDQuote || inQuote)
sb.Append (c);
else {
if (name != String.Empty && name != null) {
value = sb.ToString ();
// FIXME - KeywordLookup is an NOP
// options [KeywordLookup (name.Trim ())] = value;
options [name.Trim ()] = value;
}
inName = true;
name = String.Empty;
value = String.Empty;
sb = new StringBuilder ();
}
break;
case '=':
if (inDQuote || inQuote || !inName)
sb.Append (c);
else if (peek.Equals (c)) {
sb.Append (c);
i += 1;
}
else {
name = sb.ToString ();
sb = new StringBuilder ();
inName = false;
}
break;
case ' ':
if (inQuote || inDQuote)
sb.Append (c);
else if (sb.Length > 0 && !peek.Equals (';'))
sb.Append (c);
break;
default:
sb.Append (c);
break;
}
}
StringBuilder normalized = new StringBuilder ();
ArrayList keys = new ArrayList ();
keys.AddRange (Keys);
keys.Sort ();
foreach (string key in keys)
{
string entry = String.Format ("{0}=\"{1}\";", key, this [key].Replace ("\"", "\"\""));
normalized.Append (entry);
}
normalizedConnectionString = normalized.ToString ();
}
#endregion // Methods
}
}
#endif

View File

@@ -1,113 +0,0 @@
//
// System.Data.Common.DbConnectionString
//
// Authors:
// Tim Coleman (tim@timcoleman.com)
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) Tim Coleman, 2003
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System.Collections;
using System.Collections.Specialized;
using System.Runtime.Serialization;
using System.Text;
namespace System.Data.Common {
[Obsolete ()]
internal class DbConnectionString : DbConnectionOptions, ISerializable {
#region Fields
KeyRestrictionBehavior behavior;
#endregion // Fields
#region Constructors
protected internal DbConnectionString (DbConnectionString constr)
{
options = constr.options;
}
public DbConnectionString (string connectionString)
: base (connectionString)
{
options = new NameValueCollection ();
ParseConnectionString (connectionString);
}
[MonoTODO]
protected DbConnectionString (SerializationInfo si, StreamingContext sc)
{
}
[MonoTODO]
public DbConnectionString (string connectionString, string restrictions, KeyRestrictionBehavior behavior)
: this (connectionString)
{
this.behavior = behavior;
}
#endregion // Constructors
#region Properties
public KeyRestrictionBehavior Behavior {
get { return behavior; }
}
[MonoTODO]
public string Restrictions {
get { throw new NotImplementedException (); }
}
#endregion // Properties
#region Methods
[MonoTODO]
public virtual void GetObjectData (SerializationInfo info, StreamingContext context)
{
throw new NotImplementedException ();
}
protected virtual string KeywordLookup (string keyname)
{
return keyname;
}
[MonoTODO]
public virtual void PermissionDemand ()
{
throw new NotImplementedException ();
}
#endregion // Methods
}
}
#endif

View File

@@ -26,7 +26,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Data;
@@ -60,4 +59,3 @@ namespace System.Data.Common
}
}
#endif // NET_2_0

View File

@@ -43,11 +43,7 @@ using System.Runtime.InteropServices;
namespace System.Data.Common
{
#if NET_2_0
public abstract class DbDataAdapter : DataAdapter, IDbDataAdapter, IDataAdapter, ICloneable
#else
public abstract class DbDataAdapter : DataAdapter, ICloneable
#endif
{
#region Fields
@@ -55,12 +51,10 @@ namespace System.Data.Common
const string DefaultSourceColumnName = "Column";
CommandBehavior _behavior = CommandBehavior.Default;
#if NET_2_0
IDbCommand _selectCommand;
IDbCommand _updateCommand;
IDbCommand _deleteCommand;
IDbCommand _insertCommand;
#endif
#endregion // Fields
@@ -78,7 +72,6 @@ namespace System.Data.Common
#region Properties
#if NET_2_0
protected internal CommandBehavior FillCommandBehavior {
get { return _behavior; }
set { _behavior = value; }
@@ -172,23 +165,11 @@ namespace System.Data.Common
throw new NotSupportedException ();
}
}
#endif
#endregion // Properties
#region Events
#if ONLY_1_0 || ONLY_1_1
[DataCategory ("Fill")]
[DataSysDescription ("Event triggered when a recoverable error occurs during Fill.")]
public event FillErrorEventHandler FillError;
#endif
#endregion // Events
#region Methods
#if NET_2_0
protected virtual RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command,
StatementType statementType,
DataTableMapping tableMapping)
@@ -224,18 +205,6 @@ namespace System.Data.Common
}
}
}
#else
protected abstract RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command,
StatementType statementType,
DataTableMapping tableMapping);
protected abstract RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command,
StatementType statementType,
DataTableMapping tableMapping);
protected abstract void OnRowUpdated (RowUpdatedEventArgs value);
protected abstract void OnRowUpdating (RowUpdatingEventArgs value);
#endif
protected override void Dispose (bool disposing)
{
@@ -278,12 +247,6 @@ namespace System.Data.Common
return Fill (dataSet, 0, 0, srcTable, ((IDbDataAdapter) this).SelectCommand, _behavior);
}
#if !NET_2_0
protected virtual int Fill (DataTable dataTable, IDataReader dataReader)
{
return base.FillInternal (dataTable, dataReader);
}
#endif
protected virtual int Fill (DataTable dataTable, IDbCommand command, CommandBehavior behavior)
{
@@ -302,7 +265,6 @@ namespace System.Data.Common
return this.Fill (dataSet, startRecord, maxRecords, srcTable, ((IDbDataAdapter) this).SelectCommand, _behavior);
}
#if NET_2_0
[MonoTODO]
public int Fill (int startRecord, int maxRecords, params DataTable[] dataTables)
{
@@ -314,12 +276,6 @@ namespace System.Data.Common
{
throw new NotImplementedException ();
}
#else
protected virtual int Fill (DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords)
{
return base.FillInternal (dataSet, srcTable, dataReader, startRecord, maxRecords);
}
#endif
protected virtual int Fill (DataSet dataSet, int startRecord, int maxRecords, string srcTable, IDbCommand command, CommandBehavior behavior)
{
@@ -338,7 +294,6 @@ namespace System.Data.Common
startRecord, maxRecords);
}
#if NET_2_0
/// <summary>
/// Fills the given datatable using values from reader. if a value
/// for a column is null, that will be filled with default value.
@@ -407,7 +362,6 @@ namespace System.Data.Common
}
return counter;
}
#endif // NET_2_0
public override DataTable [] FillSchema (DataSet dataSet, SchemaType schemaType)
{
@@ -684,9 +638,6 @@ namespace System.Data.Common
try {
if (command != null) {
DataColumnMappingCollection columnMappings = tableMapping.ColumnMappings;
#if ONLY_1_1
IDataParameter nullCheckParam = null;
#endif
foreach (IDataParameter parameter in command.Parameters) {
if ((parameter.Direction & ParameterDirection.Input) == 0)
continue;
@@ -697,7 +648,6 @@ namespace System.Data.Common
rowVersion = DataRowVersion.Original;
string dsColumnName = parameter.SourceColumn;
#if NET_2_0
if (columnMappings.Contains(dsColumnName)) {
dsColumnName = columnMappings [dsColumnName].DataSetColumn;
parameter.Value = row [dsColumnName, rowVersion];
@@ -706,21 +656,8 @@ namespace System.Data.Common
}
DbParameter nullCheckParam = parameter as DbParameter;
#else
if (columnMappings.Contains(dsColumnName))
dsColumnName = columnMappings [dsColumnName].DataSetColumn;
if (dsColumnName == null || dsColumnName.Length == 0) {
nullCheckParam = parameter;
continue;
}
parameter.Value = row [dsColumnName, rowVersion];
#endif
#if NET_2_0
if (nullCheckParam != null && nullCheckParam.SourceColumnNullMapping) {
#else
if (nullCheckParam != null) {
#endif
if (parameter.Value != null && parameter.Value != DBNull.Value)
nullCheckParam.Value = 0;
else
@@ -836,10 +773,8 @@ namespace System.Data.Common
case UpdateStatus.SkipAllRemainingRows:
return updateCount;
}
#if NET_2_0
if (!AcceptChangesDuringUpdate)
continue;
#endif
row.AcceptChanges ();
} catch (Exception e) {
row.RowError = e.Message;
@@ -891,7 +826,6 @@ namespace System.Data.Common
return Update (dataTable, tableMapping);
}
#if NET_2_0
// All the batch methods, should be implemented, if supported,
// by individual providers
@@ -936,18 +870,6 @@ namespace System.Data.Common
{
return new NotSupportedException ("Method is not supported.");
}
#else
internal override void OnFillErrorInternal (FillErrorEventArgs value)
{
OnFillError (value);
}
protected virtual void OnFillError (FillErrorEventArgs value)
{
if (FillError != null)
FillError (this, value);
}
#endif
#endregion // Methods
}
}

View File

@@ -1,317 +0,0 @@
//
// System.Data.Common.DbDataPermission.cs
//
// Authors:
// Rodrigo Moya (rodrigo@ximian.com)
// Tim Coleman (tim@timcoleman.com)
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) Ximian, Inc
// Copyright (C) Tim Coleman, 2002-2003
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.Security;
using System.Security.Permissions;
namespace System.Data.Common {
[Serializable]
public abstract class DBDataPermission : CodeAccessPermission, IUnrestrictedPermission {
#region Fields
private const int version = 1;
private bool allowBlankPassword;
private PermissionState state;
private Hashtable _connections;
#endregion // Fields
#region Constructors
#if NET_2_0
[Obsolete ("use DBDataPermission (PermissionState.None)", true)]
#endif
protected DBDataPermission ()
: this (PermissionState.None)
{
}
protected DBDataPermission (DBDataPermission permission)
{
if (permission == null)
throw new ArgumentNullException ("permission");
state = permission.state;
if (state != PermissionState.Unrestricted) {
allowBlankPassword = permission.allowBlankPassword;
_connections = (Hashtable) permission._connections.Clone ();
}
}
protected DBDataPermission (DBDataPermissionAttribute permissionAttribute)
{
if (permissionAttribute == null)
throw new ArgumentNullException ("permissionAttribute");
_connections = new Hashtable ();
if (permissionAttribute.Unrestricted) {
state = PermissionState.Unrestricted;
}
else {
state = PermissionState.None;
allowBlankPassword = permissionAttribute.AllowBlankPassword;
if (permissionAttribute.ConnectionString.Length > 0) {
Add (permissionAttribute.ConnectionString, permissionAttribute.KeyRestrictions,
permissionAttribute.KeyRestrictionBehavior);
}
}
}
protected DBDataPermission (PermissionState state)
{
this.state = PermissionHelper.CheckPermissionState (state, true);
_connections = new Hashtable ();
}
#if NET_2_0
[Obsolete ("use DBDataPermission (PermissionState.None)", true)]
protected
#else
public
#endif
DBDataPermission (PermissionState state, bool allowBlankPassword)
: this (state)
{
this.allowBlankPassword = allowBlankPassword;
}
#endregion // Constructors
#region Properties
public bool AllowBlankPassword {
get { return allowBlankPassword; }
set { allowBlankPassword = value; }
}
#endregion // Properties
#region Methods
public virtual void Add (string connectionString, string restrictions, KeyRestrictionBehavior behavior)
{
state = PermissionState.None;
_connections [connectionString] = new object [2] { restrictions, behavior };
}
protected void Clear ()
{
_connections.Clear ();
}
public override IPermission Copy ()
{
DBDataPermission dbdp = CreateInstance ();
dbdp.allowBlankPassword = this.allowBlankPassword;
dbdp._connections = (Hashtable) this._connections.Clone ();
return dbdp;
}
protected virtual DBDataPermission CreateInstance ()
{
return (DBDataPermission) Activator.CreateInstance (this.GetType (), new object [1] { PermissionState.None });
}
public override void FromXml (SecurityElement securityElement)
{
PermissionHelper.CheckSecurityElement (securityElement, "securityElement", version, version);
// Note: we do not (yet) care about the return value
// as we only accept version 1 (min/max values)
state = (PermissionHelper.IsUnrestricted (securityElement) ?
PermissionState.Unrestricted : PermissionState.None);
allowBlankPassword = false;
string blank = securityElement.Attribute ("AllowBlankPassword");
if (blank != null) {
#if NET_2_0
// avoid possible exceptions with Fx 2.0
if (!Boolean.TryParse (blank, out allowBlankPassword))
allowBlankPassword = false;
#else
try {
allowBlankPassword = Boolean.Parse (blank);
}
catch {
allowBlankPassword = false;
}
#endif
}
if (securityElement.Children != null) {
foreach (SecurityElement child in securityElement.Children) {
string connect = child.Attribute ("ConnectionString");
string restricts = child.Attribute ("KeyRestrictions");
KeyRestrictionBehavior behavior = (KeyRestrictionBehavior) Enum.Parse (
typeof (KeyRestrictionBehavior), child.Attribute ("KeyRestrictionBehavior"));
if ((connect != null) && (connect.Length > 0))
Add (connect, restricts, behavior);
}
}
}
public override IPermission Intersect (IPermission target)
{
// FIXME: restrictions not completely implemented - nor documented
DBDataPermission dbdp = Cast (target);
if (dbdp == null)
return null;
if (IsUnrestricted ()) {
if (dbdp.IsUnrestricted ()) {
DBDataPermission u = CreateInstance ();
u.state = PermissionState.Unrestricted;
return u;
}
return dbdp.Copy ();
}
if (dbdp.IsUnrestricted ())
return Copy ();
if (IsEmpty () || dbdp.IsEmpty ())
return null;
DBDataPermission p = CreateInstance ();
p.allowBlankPassword = (allowBlankPassword && dbdp.allowBlankPassword);
foreach (DictionaryEntry de in _connections) {
object o = dbdp._connections [de.Key];
if (o != null)
p._connections.Add (de.Key, de.Value);
}
return (p._connections.Count > 0) ? p : null;
}
public override bool IsSubsetOf (IPermission target)
{
// FIXME: restrictions not completely implemented - nor documented
DBDataPermission dbdp = Cast (target);
if (dbdp == null)
return IsEmpty ();
if (dbdp.IsUnrestricted ())
return true;
if (IsUnrestricted ())
return dbdp.IsUnrestricted ();
if (allowBlankPassword && !dbdp.allowBlankPassword)
return false;
if (_connections.Count > dbdp._connections.Count)
return false;
foreach (DictionaryEntry de in _connections) {
object o = dbdp._connections [de.Key];
if (o == null)
return false;
// FIXME: this is a subset of what is required
// it seems that we must process both the connect string
// and the restrictions - but this has other effects :-/
}
return true;
}
public bool IsUnrestricted ()
{
return (state == PermissionState.Unrestricted);
}
public override SecurityElement ToXml ()
{
SecurityElement se = PermissionHelper.Element (this.GetType (), version);
if (IsUnrestricted ()) {
se.AddAttribute ("Unrestricted", "true");
}
else {
// attribute is present for both True and False
se.AddAttribute ("AllowBlankPassword", allowBlankPassword.ToString ());
foreach (DictionaryEntry de in _connections) {
SecurityElement child = new SecurityElement ("add");
child.AddAttribute ("ConnectionString", (string) de.Key);
object[] restrictionsInfo = (object[]) de.Value;
child.AddAttribute ("KeyRestrictions", (string) restrictionsInfo [0]);
KeyRestrictionBehavior krb = (KeyRestrictionBehavior) restrictionsInfo [1];
child.AddAttribute ("KeyRestrictionBehavior", krb.ToString ());
se.AddChild (child);
}
}
return se;
}
public override IPermission Union (IPermission target)
{
// FIXME: restrictions not completely implemented - nor documented
DBDataPermission dbdp = Cast (target);
if (dbdp == null)
return Copy ();
if (IsEmpty () && dbdp.IsEmpty ())
return Copy ();
DBDataPermission p = CreateInstance ();
if (IsUnrestricted () || dbdp.IsUnrestricted ()) {
p.state = PermissionState.Unrestricted;
}
else {
p.allowBlankPassword = (allowBlankPassword || dbdp.allowBlankPassword);
p._connections = new Hashtable (_connections.Count + dbdp._connections.Count);
foreach (DictionaryEntry de in _connections)
p._connections.Add (de.Key, de.Value);
// don't duplicate
foreach (DictionaryEntry de in dbdp._connections)
p._connections [de.Key] = de.Value;
}
return p;
}
// helpers
private bool IsEmpty ()
{
return ((state != PermissionState.Unrestricted) && (_connections.Count == 0));
}
private DBDataPermission Cast (IPermission target)
{
if (target == null)
return null;
DBDataPermission dbdp = (target as DBDataPermission);
if (dbdp == null) {
PermissionHelper.ThrowInvalidPermission (target, this.GetType ());
}
return dbdp;
}
#endregion // Methods
}
}

View File

@@ -1,113 +0,0 @@
//
// System.Data.Common.DbDataPermissionAttribute.cs
//
// Authors:
// Rodrigo Moya (rodrigo@ximian.com)
// Tim Coleman (tim@timcoleman.com)
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) Ximian, Inc
// Copyright (C) Tim Coleman, 2002
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.Security.Permissions;
using System.Globalization;
namespace System.Data.Common {
[AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Class |
AttributeTargets.Struct | AttributeTargets.Constructor |
AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
[Serializable]
public abstract class DBDataPermissionAttribute : CodeAccessSecurityAttribute {
#region Fields
bool allowBlankPassword;
string keyRestrictions;
KeyRestrictionBehavior keyRestrictionBehavior;
string connectionString;
#endregion // Fields
#region Constructors
protected DBDataPermissionAttribute (SecurityAction action)
: base (action)
{
}
#endregion // Constructors
#region Properties
public bool AllowBlankPassword {
get { return allowBlankPassword; }
set { allowBlankPassword = value; }
}
public string KeyRestrictions {
get {
if (keyRestrictions == null)
return String.Empty;
return keyRestrictions;
}
set { keyRestrictions = value; }
}
public string ConnectionString {
get {
if (connectionString == null)
return String.Empty;
return connectionString;
}
set { connectionString = value; }
}
public KeyRestrictionBehavior KeyRestrictionBehavior {
get { return keyRestrictionBehavior; }
set {
ExceptionHelper.CheckEnumValue (typeof (KeyRestrictionBehavior), value);
keyRestrictionBehavior = value;
}
}
#endregion // Properties
#region // Methods
[EditorBrowsableAttribute (EditorBrowsableState.Never)]
public bool ShouldSerializeConnectionString ()
{
// FIXME: configurable ? why is this in the attribute class ?
return false;
}
[EditorBrowsableAttribute (EditorBrowsableState.Never)]
public bool ShouldSerializeKeyRestrictions ()
{
// FIXME: configurable ? why is this in the attribute class ?
return false;
}
#endregion // Methods
}
}

View File

@@ -35,10 +35,8 @@ using System.ComponentModel;
using System.Data;
using System.IO;
#if NET_4_5
using System.Threading;
using System.Threading.Tasks;
#endif
namespace System.Data.Common {
public abstract class DbDataReader : MarshalByRefObject, IDataReader, IDataRecord, IDisposable, IEnumerable
@@ -61,11 +59,9 @@ namespace System.Data.Common {
public abstract object this [string name] { get; }
public abstract int RecordsAffected { get; }
#if NET_2_0
public virtual int VisibleFieldCount {
get { return FieldCount; }
}
#endif
#endregion // Properties
#region Methods
@@ -88,13 +84,11 @@ namespace System.Data.Common {
if (disposing)
Close ();
}
#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Never)]
public DbDataReader GetData (int ordinal)
{
return ((DbDataReader) this [ordinal]);
}
#endif
public abstract string GetDataTypeName (int ordinal);
public abstract DateTime GetDateTime (int ordinal);
@@ -113,7 +107,6 @@ namespace System.Data.Common {
public abstract string GetName (int ordinal);
public abstract int GetOrdinal (string name);
#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Never)]
public virtual Type GetProviderSpecificFieldType (int ordinal)
{
@@ -136,7 +129,6 @@ namespace System.Data.Common {
{
return ((DbDataReader) this [ordinal]);
}
#endif
public abstract DataTable GetSchemaTable ();
public abstract string GetString (int ordinal);
@@ -188,7 +180,6 @@ namespace System.Data.Common {
return schemaTable;
}
#if NET_4_5
public virtual T GetFieldValue<T> (int i)
{
return (T) GetValue (i);
@@ -290,7 +281,6 @@ namespace System.Data.Common {
return TaskHelper.CreateExceptionTask<bool> (e);
}
}
#endif
#endregion // Methods
}

View File

@@ -1,369 +0,0 @@
//
// System.Data.Common.DbDataRecord.cs
//
// Author:
// Tim Coleman (tim@timcoleman.com)
//
// Copyright (C) Tim Coleman, 2002-2003
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Runtime.CompilerServices;
namespace System.Data.Common
{
public abstract class DbDataRecord : IDataRecord, ICustomTypeDescriptor
{
protected DbDataRecord ()
{
}
public abstract int FieldCount { get; }
public abstract object this [string name] { get; }
public abstract object this [int i] { get; }
public abstract bool GetBoolean (int i);
public abstract byte GetByte (int i);
public abstract long GetBytes (int i, long dataIndex, byte [] buffer, int bufferIndex,int length);
public abstract char GetChar (int i);
public abstract long GetChars (int i, long dataIndex, char [] buffer, int bufferIndex, int length);
public abstract string GetDataTypeName (int i);
public abstract DateTime GetDateTime (int i);
public abstract decimal GetDecimal (int i);
public abstract double GetDouble (int i);
public abstract Type GetFieldType (int i);
public abstract float GetFloat (int i);
public abstract Guid GetGuid (int i);
public abstract short GetInt16 (int i);
public abstract int GetInt32 (int i);
public abstract long GetInt64 (int i);
public abstract string GetName (int i);
public abstract int GetOrdinal (string name);
public abstract string GetString (int i);
public abstract object GetValue (int i);
public abstract int GetValues (object [] values);
public abstract bool IsDBNull (int i);
public IDataReader GetData (int i)
{
return (IDataReader) GetValue (i);
}
protected virtual DbDataReader GetDbDataReader (int i)
{
throw new NotSupportedException ();
}
[MonoTODO]
AttributeCollection ICustomTypeDescriptor.GetAttributes ()
{
return new AttributeCollection (null);
}
[MonoTODO]
string ICustomTypeDescriptor.GetClassName ()
{
return string.Empty;
}
[MonoTODO]
string ICustomTypeDescriptor.GetComponentName ()
{
return null;
}
[MonoTODO]
TypeConverter ICustomTypeDescriptor.GetConverter ()
{
return null;
}
[MonoTODO]
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent ()
{
return null;
}
[MonoTODO]
PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty ()
{
return null;
}
[MonoTODO]
object ICustomTypeDescriptor.GetEditor (Type editorBaseType)
{
return null;
}
[MonoTODO]
EventDescriptorCollection ICustomTypeDescriptor.GetEvents ()
{
return new EventDescriptorCollection (null);
}
[MonoTODO]
EventDescriptorCollection ICustomTypeDescriptor.GetEvents (Attribute [] attributes)
{
return new EventDescriptorCollection (null);
}
[MonoTODO]
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties ()
{
DataColumnPropertyDescriptor[] descriptors =
new DataColumnPropertyDescriptor [FieldCount];
DataColumnPropertyDescriptor descriptor;
for (int col = 0; col < FieldCount; col++) {
descriptor = new DataColumnPropertyDescriptor(
GetName (col), col, null);
descriptor.SetComponentType (typeof (DbDataRecord));
descriptor.SetPropertyType (GetFieldType (col));
descriptors [col] = descriptor;
}
return new PropertyDescriptorCollection (descriptors);
}
[MonoTODO]
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties (Attribute [] attributes)
{
PropertyDescriptorCollection descriptors;
descriptors = ((ICustomTypeDescriptor) this).GetProperties ();
// TODO: filter out descriptors which do not contain
// any of those attributes
// except, those descriptors
// that contain DefaultMemeberAttribute
return descriptors;
}
[MonoTODO]
object ICustomTypeDescriptor.GetPropertyOwner (PropertyDescriptor pd)
{
return this;
}
}
class DbDataRecordImpl : DbDataRecord
{
#region Fields
readonly SchemaInfo [] schema;
readonly object [] values;
readonly int fieldCount;
#endregion
#region Constructors
// FIXME: this class should actually be reimplemented to be one
// of the derived classes of DbDataRecord, which should become
// almost abstract.
internal DbDataRecordImpl (SchemaInfo[] schema, object[] values)
{
this.schema = schema;
this.values = values;
this.fieldCount = values.Length;
}
#endregion
#region Properties
public override int FieldCount {
get { return fieldCount; }
}
public override object this [string name] {
get { return this [GetOrdinal (name)]; }
}
public override object this [int i] {
get { return GetValue (i); }
}
#endregion
#region Methods
public override bool GetBoolean (int i)
{
return (bool) GetValue (i);
}
public override byte GetByte (int i)
{
return (byte) GetValue (i);
}
public override long GetBytes (int i, long dataIndex, byte[] buffer, int bufferIndex, int length)
{
object value = GetValue (i);
if (!(value is byte []))
throw new InvalidCastException ("Type is " + value.GetType ().ToString ());
if ( buffer == null ) {
// Return length of data
return ((byte []) value).Length;
} else {
// Copy data into buffer
Array.Copy ((byte []) value, (int) dataIndex, buffer, bufferIndex, length);
return ((byte []) value).Length - dataIndex;
}
}
public override char GetChar (int i)
{
return (char) GetValue (i);
}
public override long GetChars (int i, long dataIndex, char[] buffer, int bufferIndex, int length)
{
object value = GetValue (i);
char [] valueBuffer;
if (value is char[])
valueBuffer = (char []) value;
else if (value is string)
valueBuffer = ((string) value).ToCharArray ();
else
throw new InvalidCastException ("Type is " + value.GetType ().ToString ());
if (buffer == null) {
// Return length of data
return valueBuffer.Length;
} else {
// Copy data into buffer
Array.Copy (valueBuffer, (int) dataIndex, buffer, bufferIndex, length);
return valueBuffer.Length - dataIndex;
}
}
public override string GetDataTypeName (int i)
{
return schema[i].DataTypeName;
}
public override DateTime GetDateTime (int i)
{
return (DateTime) GetValue (i);
}
#if NET_2_0
[MonoTODO]
protected override DbDataReader GetDbDataReader (int ordinal)
{
throw new NotImplementedException ();
}
#endif
public override decimal GetDecimal (int i)
{
return (decimal) GetValue (i);
}
public override double GetDouble (int i)
{
return (double) GetValue (i);
}
public override Type GetFieldType (int i)
{
return schema[i].FieldType;
}
public override float GetFloat (int i)
{
return (float) GetValue (i);
}
public override Guid GetGuid (int i)
{
return (Guid) GetValue (i);
}
public override short GetInt16 (int i)
{
return (short) GetValue (i);
}
public override int GetInt32 (int i)
{
return (int) GetValue (i);
}
public override long GetInt64 (int i)
{
return (long) GetValue (i);
}
public override string GetName (int i)
{
return schema [i].ColumnName;
}
public override int GetOrdinal (string name)
{
for (int i = 0; i < FieldCount; i++)
if (schema [i].ColumnName == name)
return i;
return -1;
}
public override string GetString (int i)
{
return (string) GetValue (i);
}
public override object GetValue (int i)
{
if (i < 0 || i > fieldCount)
throw new IndexOutOfRangeException ();
return values [i];
}
public override int GetValues (object[] values)
{
if (values == null)
throw new ArgumentNullException("values");
int count = values.Length > this.values.Length ? this.values.Length : values.Length;
for(int i = 0; i < count; i++)
values [i] = this.values [i];
return count;
}
public override bool IsDBNull (int i)
{
return GetValue (i) == DBNull.Value;
}
#endregion // Methods
}
}

Some files were not shown because too many files have changed in this diff Show More