Imported Upstream version 4.2.0.179

Former-commit-id: 4610231f55806d2a05ed69e5ff3faa7336cc1479
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent aa7da660d6
commit c042cd0c52
7507 changed files with 90259 additions and 657307 deletions

View File

@@ -1,41 +0,0 @@
//
// System.Data.Common.CatalogLocation.cs
//
// Author:
// Tim Coleman (tim@timcoleman.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.
//
namespace System.Data.Common {
public enum CatalogLocation
{
End = 2,
Start = 1
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,169 +0,0 @@
//
// 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;
namespace System.Data.Common
{
/// <summary>
/// Summary description for ComparerFactory.
/// </summary>
internal class DBComparerFactory
{
private static IComparer comparableComparer = new ComparebleComparer();
private static IComparer ignoreCaseComparer = new IgnoreCaseComparer();
private static IComparer caseComparer = new CaseComparer();
private static IComparer byteArrayComparer = new ByteArrayComparer();
private static Type icomparerType = typeof (IComparable);
public static IComparer GetComparer (Type type, bool ignoreCase)
{
if (type == typeof (string)) {
if (ignoreCase)
return ignoreCaseComparer;
return caseComparer;
}
if (icomparerType.IsAssignableFrom(type))
return comparableComparer;
if (type == typeof (byte[]))
return byteArrayComparer;
return null;
}
class ComparebleComparer :IComparer
{
#region IComparer Members
public int Compare(object x, object y)
{
if (x == DBNull.Value) {
if (y == DBNull.Value)
return 0;
return -1;
}
if (y == DBNull.Value)
return 1;
return ((IComparable)x).CompareTo (y);
}
#endregion
}
class CaseComparer : IComparer
{
#region IComparer Members
public int Compare(object x, object y)
{
if (x == DBNull.Value) {
if (y == DBNull.Value)
return 0;
return -1;
}
if (y == DBNull.Value)
return 1;
return String.Compare ((string)x, (string)y, false);
}
#endregion
}
class IgnoreCaseComparer : IComparer
{
#region IComparer Members
public int Compare(object x, object y)
{
if (x == DBNull.Value) {
if (y == DBNull.Value)
return 0;
return -1;
}
if (y == DBNull.Value)
return 1;
return String.Compare ((string)x, (string)y, true);
}
#endregion
}
class ByteArrayComparer : IComparer
{
#region IComparer Members
public int Compare(object x, object y)
{
if (x == DBNull.Value) {
if (y == DBNull.Value)
return 0;
return -1;
}
if (y == DBNull.Value)
return 1;
byte[] o1 = (byte[])x;
byte[] o2 = (byte[])y;
int len = o1.Length;
int lenb = o2.Length;
for (int i = 0; ; i++) {
int a = 0;
int b = 0;
if (i < len) {
a = o1[i];
}
else if (i >= lenb) {
return 0;
}
if (i < lenb) {
b = o2[i];
}
if (a > b) {
return 1;
}
if (b > a) {
return -1;
}
}
}
#endregion
}
}
}

File diff suppressed because it is too large Load Diff

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 ();
}
}
}

File diff suppressed because it is too large Load Diff

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

@@ -1,240 +0,0 @@
//
// System.Data.Common.DbCommand
//
// Author:
// Tim Coleman (tim@timcoleman.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.
//
using System.ComponentModel;
using System.Data;
using System.Threading;
using System.Threading.Tasks;
namespace System.Data.Common {
public abstract class DbCommand : Component, IDbCommand, IDisposable
{
protected DbCommand ()
{
}
#region Properties
[DefaultValue ("")]
[RefreshProperties (RefreshProperties.All)]
public abstract string CommandText { get; set; }
public abstract int CommandTimeout { get; set; }
[DefaultValue (CommandType.Text)]
[RefreshProperties (RefreshProperties.All)]
public abstract CommandType CommandType { get; set; }
[DefaultValue (null)]
[Browsable (false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public DbConnection Connection {
get { return DbConnection; }
set { DbConnection = value; }
}
protected abstract DbConnection DbConnection { get; set; }
protected abstract DbParameterCollection DbParameterCollection { get; }
protected abstract DbTransaction DbTransaction { get; set; }
[EditorBrowsable (EditorBrowsableState.Never)]
[Browsable (false)]
[DefaultValue (true)]
[DesignOnly (true)]
public abstract bool DesignTimeVisible { get; set; }
IDbConnection IDbCommand.Connection {
get { return Connection; }
set { Connection = (DbConnection) value; }
}
IDataParameterCollection IDbCommand.Parameters {
get { return Parameters; }
}
IDbTransaction IDbCommand.Transaction {
get { return Transaction; }
set { Transaction = (DbTransaction) value; }
}
[Browsable (false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public DbParameterCollection Parameters {
get { return DbParameterCollection; }
}
[Browsable (false)]
[DefaultValue (null)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public DbTransaction Transaction {
get { return DbTransaction; }
set { DbTransaction = value; }
}
[DefaultValue (UpdateRowSource.Both)]
public abstract UpdateRowSource UpdatedRowSource { get; set; }
#endregion // Properties
#region Methods
public abstract void Cancel ();
protected abstract DbParameter CreateDbParameter ();
public DbParameter CreateParameter ()
{
return CreateDbParameter ();
}
protected abstract DbDataReader ExecuteDbDataReader (CommandBehavior behavior);
public abstract int ExecuteNonQuery ();
public DbDataReader ExecuteReader ()
{
return ExecuteDbDataReader (CommandBehavior.Default);
}
public DbDataReader ExecuteReader (CommandBehavior behavior)
{
return ExecuteDbDataReader (behavior);
}
public abstract object ExecuteScalar ();
IDbDataParameter IDbCommand.CreateParameter ()
{
return CreateParameter ();
}
IDataReader IDbCommand.ExecuteReader ()
{
return ExecuteReader ();
}
IDataReader IDbCommand.ExecuteReader (CommandBehavior behavior)
{
return ExecuteReader (behavior);
}
public abstract void Prepare ();
protected virtual Task<DbDataReader> ExecuteDbDataReaderAsync (CommandBehavior behavior, CancellationToken cancellationToken)
{
if (cancellationToken.IsCancellationRequested) {
return TaskHelper.CreateCanceledTask<DbDataReader> ();
}
try {
return Task.FromResult (ExecuteDbDataReader (behavior));
} catch (Exception e) {
return TaskHelper.CreateExceptionTask<DbDataReader> (e);
}
}
public Task<int> ExecuteNonQueryAsync ()
{
return ExecuteNonQueryAsync (CancellationToken.None);
}
public virtual Task<int> ExecuteNonQueryAsync (CancellationToken cancellationToken)
{
if (cancellationToken.IsCancellationRequested) {
return TaskHelper.CreateCanceledTask<int> ();
}
try {
return Task.FromResult (ExecuteNonQuery ());
} catch (Exception e) {
return TaskHelper.CreateExceptionTask<int> (e);
}
}
public Task<Object> ExecuteScalarAsync ()
{
return ExecuteScalarAsync (CancellationToken.None);
}
public virtual Task<Object> ExecuteScalarAsync (CancellationToken cancellationToken)
{
if (cancellationToken.IsCancellationRequested) {
return TaskHelper.CreateCanceledTask<Object> ();
}
try {
return Task.FromResult (ExecuteScalar ());
} catch (Exception e) {
return TaskHelper.CreateExceptionTask<Object> (e);
}
}
public Task<DbDataReader> ExecuteReaderAsync ()
{
return ExecuteReaderAsync (CancellationToken.None);
}
public Task<DbDataReader> ExecuteReaderAsync (CancellationToken cancellationToken)
{
if (cancellationToken.IsCancellationRequested) {
return TaskHelper.CreateCanceledTask<DbDataReader> ();
}
try {
return Task.FromResult (ExecuteReader ());
} catch (Exception e) {
return TaskHelper.CreateExceptionTask<DbDataReader> (e);
}
}
public Task<DbDataReader> ExecuteReaderAsync (CommandBehavior behavior)
{
return ExecuteReaderAsync (behavior, CancellationToken.None);
}
public Task<DbDataReader> ExecuteReaderAsync (CommandBehavior behavior, CancellationToken cancellationToken)
{
if (cancellationToken.IsCancellationRequested) {
return TaskHelper.CreateCanceledTask<DbDataReader> ();
}
try {
return Task.FromResult (ExecuteReader (behavior));
} catch (Exception e) {
return TaskHelper.CreateExceptionTask<DbDataReader> (e);
}
}
#endregion // Methods
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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
}
}

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