Imported Upstream version 4.4.2.4

Former-commit-id: 92904c9c5915c37244316e42ba99e7b934ed7ee2
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-07-21 09:40:10 +00:00
parent 589d484eee
commit 0b4a830db1
343 changed files with 9849 additions and 688 deletions

View File

@@ -0,0 +1,64 @@
//
// DbColumn.cs
//
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.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.Generic;
namespace System.Data.Common
{
public abstract class DbColumn
{
public bool? AllowDBNull { get; protected set; }
public string BaseCatalogName { get; protected set; }
public string BaseColumnName { get; protected set; }
public string BaseSchemaName { get; protected set; }
public string BaseServerName { get; protected set; }
public string BaseTableName { get; protected set; }
public string ColumnName { get; protected set; }
public int? ColumnOrdinal { get; protected set; }
public int? ColumnSize { get; protected set; }
public bool? IsAliased { get; protected set; }
public bool? IsAutoIncrement { get; protected set; }
public bool? IsExpression { get; protected set; }
public bool? IsHidden { get; protected set; }
public bool? IsIdentity { get; protected set; }
public bool? IsKey { get; protected set; }
public bool? IsLong { get; protected set; }
public bool? IsReadOnly { get; protected set; }
public bool? IsUnique { get; protected set; }
public int? NumericPrecision { get; protected set; }
public int? NumericScale { get; protected set; }
public string UdtAssemblyQualifiedName { get; protected set; }
public Type DataType { get; protected set; }
public string DataTypeName { get; protected set; }
public virtual object this[string property] {
get {
throw new NotImplementedException ();
}
}
}
}

View File

@@ -0,0 +1,85 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
namespace System.Data.Common
{
internal class DataRowDbColumn : DbColumn
{
private DataColumnCollection schemaColumns;
private DataRow schemaRow;
public DataRowDbColumn(DataRow readerSchemaRow, DataColumnCollection readerSchemaColumns)
{
this.schemaRow = readerSchemaRow;
this.schemaColumns = readerSchemaColumns;
populateFields();
}
private void populateFields()
{
AllowDBNull = GetDbColumnValue<bool?>(SchemaTableColumn.AllowDBNull);
BaseCatalogName = GetDbColumnValue<string>(SchemaTableOptionalColumn.BaseCatalogName);
BaseColumnName = GetDbColumnValue<string>(SchemaTableColumn.BaseColumnName);
BaseSchemaName = GetDbColumnValue<string>(SchemaTableColumn.BaseSchemaName);
BaseServerName = GetDbColumnValue<string>(SchemaTableOptionalColumn.BaseServerName);
BaseTableName = GetDbColumnValue<string>(SchemaTableColumn.BaseTableName);
ColumnName = GetDbColumnValue<string>(SchemaTableColumn.ColumnName);
ColumnOrdinal = GetDbColumnValue<int?>(SchemaTableColumn.ColumnOrdinal);
ColumnSize = GetDbColumnValue<int?>(SchemaTableColumn.ColumnSize);
IsAliased = GetDbColumnValue<bool?>(SchemaTableColumn.IsAliased);
IsAutoIncrement = GetDbColumnValue<bool?>(SchemaTableOptionalColumn.IsAutoIncrement);
IsExpression = GetDbColumnValue<bool>(SchemaTableColumn.IsExpression);
IsHidden = GetDbColumnValue<bool?>(SchemaTableOptionalColumn.IsHidden);
IsIdentity = GetDbColumnValue<bool?>("IsIdentity");
IsKey = GetDbColumnValue<bool?>(SchemaTableColumn.IsKey);
IsLong = GetDbColumnValue<bool?>(SchemaTableColumn.IsLong);
IsReadOnly = GetDbColumnValue<bool?>(SchemaTableOptionalColumn.IsReadOnly);
IsUnique = GetDbColumnValue<bool?>(SchemaTableColumn.IsUnique);
NumericPrecision = GetDbColumnValue<int?>(SchemaTableColumn.NumericPrecision);
NumericScale = GetDbColumnValue<int?>(SchemaTableColumn.NumericScale);
UdtAssemblyQualifiedName = GetDbColumnValue<string>("UdtAssemblyQualifiedName");
DataType = GetDbColumnValue<Type>(SchemaTableColumn.DataType);
DataTypeName = GetDbColumnValue<string>("DataTypeName");
}
private T GetDbColumnValue<T>(string columnName)
{
if (!schemaColumns.Contains(columnName))
{
return default(T);
}
object schemaObject = schemaRow[columnName];
if (schemaObject is T)
{
return (T)schemaObject;
}
return default(T);
}
}
public static class DbDataReaderExtensions
{
public static System.Collections.ObjectModel.ReadOnlyCollection<DbColumn> GetColumnSchema(this DbDataReader reader)
{
IList<DbColumn> columnSchema = new List<DbColumn>();
DataTable schemaTable = reader.GetSchemaTable();
DataColumnCollection schemaTableColumns = schemaTable.Columns;
foreach (DataRow row in schemaTable.Rows)
{
DbColumn dbColumn = new DataRowDbColumn(row, schemaTableColumns);
columnSchema.Add(dbColumn);
}
System.Collections.ObjectModel.ReadOnlyCollection<DbColumn> readOnlyColumnSchema = new System.Collections.ObjectModel.ReadOnlyCollection<DbColumn>(columnSchema);
return readOnlyColumnSchema;
}
public static bool CanGetColumnSchema(this DbDataReader reader)
{
return true;
}
}
}

View File

@@ -0,0 +1,35 @@
//
// IDbColumnSchemaGenerator.cs
//
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.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 interface IDbColumnSchemaGenerator
{
System.Collections.ObjectModel.ReadOnlyCollection<DbColumn> GetColumnSchema();
}
}

View File

@@ -11,7 +11,7 @@ LIBRARY = System.Data.Common.dll
KEY_FILE = ../../msfinal.pub
SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
LIB_REFS = System
LIB_REFS = System System.Xml
LIB_MCS_FLAGS = $(SIGN_FLAGS) /r:mscorlib /r:System.Data.dll
PLATFORM_DEBUG_FLAGS =

View File

@@ -1,3 +1,5 @@
TypeForwarders.cs
AssemblyInfo.cs
IDbColumnSchemaGenerator.cs
DbColumn.cs
DbDataReaderExtensions.Facade.cs

View File

@@ -20,24 +20,36 @@
// THE SOFTWARE.
//
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.DBNull))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.CommandBehavior))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.CommandType))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbCommand))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbConnection))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbConnectionStringBuilder))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbDataReader))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbDataRecord))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbEnumerator))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbException))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbParameter))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbParameterCollection))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbProviderFactory))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbTransaction))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.ConnectionState))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataRowVersion))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataTable))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DbType))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDataParameter))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDataParameterCollection))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDataReader))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDataRecord))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDbCommand))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDbConnection))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDbDataParameter))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDbTransaction))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IsolationLevel))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.ParameterDirection))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.StateChangeEventArgs))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.StateChangeEventHandler))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.UpdateRowSource))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.DBNull))]