You've already forked linux-packaging-mono
Imported Upstream version 5.10.0.47
Former-commit-id: d0813289fa2d35e1f8ed77530acb4fb1df441bc0
This commit is contained in:
parent
88ff76fe28
commit
e46a49ecf1
242
mcs/class/System.Data/corefx/Odbc/AdapterUtil.cs
Normal file
242
mcs/class/System.Data/corefx/Odbc/AdapterUtil.cs
Normal file
@@ -0,0 +1,242 @@
|
||||
// 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.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Text;
|
||||
using System.Security.Permissions;
|
||||
using System.ComponentModel;
|
||||
using System.Configuration;
|
||||
using System.Xml;
|
||||
|
||||
namespace System.Data.Common
|
||||
{
|
||||
internal static partial class ADP
|
||||
{
|
||||
internal const int DecimalMaxPrecision = 29;
|
||||
internal const int DecimalMaxPrecision28 = 28; // there are some cases in Odbc where we need that ...
|
||||
|
||||
internal static readonly IntPtr PtrZero = new IntPtr(0); // IntPtr.Zero
|
||||
internal static readonly int PtrSize = IntPtr.Size;
|
||||
|
||||
internal const string BeginTransaction = "BeginTransaction";
|
||||
internal const string ChangeDatabase = "ChangeDatabase";
|
||||
internal const string CommitTransaction = "CommitTransaction";
|
||||
internal const string CommandTimeout = "CommandTimeout";
|
||||
internal const string DeriveParameters = "DeriveParameters";
|
||||
internal const string ExecuteReader = "ExecuteReader";
|
||||
internal const string ExecuteNonQuery = "ExecuteNonQuery";
|
||||
internal const string ExecuteScalar = "ExecuteScalar";
|
||||
internal const string GetSchema = "GetSchema";
|
||||
internal const string GetSchemaTable = "GetSchemaTable";
|
||||
internal const string Prepare = "Prepare";
|
||||
internal const string RollbackTransaction = "RollbackTransaction";
|
||||
internal const string QuoteIdentifier = "QuoteIdentifier";
|
||||
internal const string UnquoteIdentifier = "UnquoteIdentifier";
|
||||
|
||||
internal static bool NeedManualEnlistment() => false;
|
||||
internal static bool IsEmpty(string str) => string.IsNullOrEmpty(str);
|
||||
|
||||
internal static Exception DatabaseNameTooLong()
|
||||
{
|
||||
return Argument(SR.GetString(SR.ADP_DatabaseNameTooLong));
|
||||
}
|
||||
|
||||
internal static int StringLength(string inputString)
|
||||
{
|
||||
return ((null != inputString) ? inputString.Length : 0);
|
||||
}
|
||||
|
||||
internal static Exception NumericToDecimalOverflow()
|
||||
{
|
||||
return InvalidCast(SR.GetString(SR.ADP_NumericToDecimalOverflow));
|
||||
}
|
||||
|
||||
internal static Exception OdbcNoTypesFromProvider()
|
||||
{
|
||||
return InvalidOperation(SR.GetString(SR.ADP_OdbcNoTypesFromProvider));
|
||||
}
|
||||
|
||||
internal static ArgumentException InvalidRestrictionValue(string collectionName, string restrictionName, string restrictionValue)
|
||||
{
|
||||
return ADP.Argument(SR.GetString(SR.MDF_InvalidRestrictionValue, collectionName, restrictionName, restrictionValue));
|
||||
}
|
||||
|
||||
internal static Exception DataReaderNoData()
|
||||
{
|
||||
return InvalidOperation(SR.GetString(SR.ADP_DataReaderNoData));
|
||||
}
|
||||
|
||||
internal static Exception ConnectionIsDisabled(Exception InnerException)
|
||||
{
|
||||
return InvalidOperation(SR.GetString(SR.ADP_ConnectionIsDisabled), InnerException);
|
||||
}
|
||||
|
||||
internal static Exception OffsetOutOfRangeException()
|
||||
{
|
||||
return InvalidOperation(SR.GetString(SR.ADP_OffsetOutOfRangeException));
|
||||
}
|
||||
|
||||
internal static ArgumentException InvalidDataType(TypeCode typecode)
|
||||
{
|
||||
return Argument(SR.GetString(SR.ADP_InvalidDataType, typecode.ToString()));
|
||||
}
|
||||
|
||||
static internal InvalidOperationException QuotePrefixNotSet(string method)
|
||||
{
|
||||
return InvalidOperation(Res.GetString(Res.ADP_QuotePrefixNotSet, method));
|
||||
}
|
||||
|
||||
[ResourceExposure(ResourceScope.Machine)]
|
||||
[ResourceConsumption(ResourceScope.Machine)]
|
||||
internal static string GetFullPath(string filename)
|
||||
{ // MDAC 77686
|
||||
return Path.GetFullPath(filename);
|
||||
}
|
||||
|
||||
internal static InvalidOperationException InvalidDataDirectory()
|
||||
{
|
||||
return ADP.InvalidOperation(SR.GetString(SR.ADP_InvalidDataDirectory));
|
||||
}
|
||||
|
||||
internal static ArgumentException UnknownDataTypeCode(Type dataType, TypeCode typeCode)
|
||||
{
|
||||
return Argument(SR.GetString(SR.ADP_UnknownDataTypeCode, ((int)typeCode).ToString(CultureInfo.InvariantCulture), dataType.FullName));
|
||||
}
|
||||
|
||||
internal static void EscapeSpecialCharacters(string unescapedString, StringBuilder escapedString)
|
||||
{
|
||||
// note special characters list is from character escapes
|
||||
// in the MSDN regular expression language elements documentation
|
||||
// added ] since escaping it seems necessary
|
||||
const string specialCharacters = ".$^{[(|)*+?\\]";
|
||||
|
||||
foreach (char currentChar in unescapedString)
|
||||
{
|
||||
if (specialCharacters.IndexOf(currentChar) >= 0)
|
||||
{
|
||||
escapedString.Append("\\");
|
||||
}
|
||||
escapedString.Append(currentChar);
|
||||
}
|
||||
}
|
||||
|
||||
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
|
||||
internal static IntPtr IntPtrOffset(IntPtr pbase, Int32 offset)
|
||||
{
|
||||
if (4 == ADP.PtrSize)
|
||||
{
|
||||
return (IntPtr)checked(pbase.ToInt32() + offset);
|
||||
}
|
||||
Debug.Assert(8 == ADP.PtrSize, "8 != IntPtr.Size"); // MDAC 73747
|
||||
return (IntPtr)checked(pbase.ToInt64() + offset);
|
||||
}
|
||||
|
||||
static internal ArgumentOutOfRangeException NotSupportedUserDefinedTypeSerializationFormat(Microsoft.SqlServer.Server.Format value, string method) {
|
||||
return ADP.NotSupportedEnumerationValue(typeof(Microsoft.SqlServer.Server.Format), value.ToString(), method);
|
||||
}
|
||||
|
||||
static internal ArgumentOutOfRangeException InvalidUserDefinedTypeSerializationFormat(Microsoft.SqlServer.Server.Format value) {
|
||||
#if DEBUG
|
||||
switch(value) {
|
||||
case Microsoft.SqlServer.Server.Format.Unknown:
|
||||
case Microsoft.SqlServer.Server.Format.Native:
|
||||
case Microsoft.SqlServer.Server.Format.UserDefined:
|
||||
Debug.Assert(false, "valid UserDefinedTypeSerializationFormat " + value.ToString());
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return InvalidEnumerationValue(typeof(Microsoft.SqlServer.Server.Format), (int) value);
|
||||
}
|
||||
|
||||
static internal ArgumentOutOfRangeException ArgumentOutOfRange(string message, string parameterName, object value) {
|
||||
ArgumentOutOfRangeException e = new ArgumentOutOfRangeException(parameterName, value, message);
|
||||
TraceExceptionAsReturnValue(e);
|
||||
return e;
|
||||
}
|
||||
|
||||
static internal Exception InvalidXMLBadVersion() {
|
||||
return Argument(Res.GetString(Res.ADP_InvalidXMLBadVersion));
|
||||
}
|
||||
|
||||
static internal Exception NotAPermissionElement() {
|
||||
return Argument(Res.GetString(Res.ADP_NotAPermissionElement));
|
||||
}
|
||||
|
||||
static internal Exception PermissionTypeMismatch() {
|
||||
return Argument(Res.GetString(Res.ADP_PermissionTypeMismatch));
|
||||
}
|
||||
|
||||
static internal ArgumentOutOfRangeException InvalidPermissionState(PermissionState value) {
|
||||
#if DEBUG
|
||||
switch(value) {
|
||||
case PermissionState.Unrestricted:
|
||||
case PermissionState.None:
|
||||
Debug.Assert(false, "valid PermissionState " + value.ToString());
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return InvalidEnumerationValue(typeof(PermissionState), (int) value);
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
static internal ConfigurationException Configuration(string message) {
|
||||
ConfigurationException e = new ConfigurationErrorsException(message);
|
||||
TraceExceptionAsReturnValue(e);
|
||||
return e;
|
||||
}
|
||||
static internal ConfigurationException Configuration(string message, XmlNode node) {
|
||||
ConfigurationException e = new ConfigurationErrorsException(message, node);
|
||||
TraceExceptionAsReturnValue(e);
|
||||
return e;
|
||||
}
|
||||
#endif
|
||||
|
||||
static internal ArgumentException ConfigProviderNotFound() {
|
||||
return Argument(Res.GetString(Res.ConfigProviderNotFound));
|
||||
}
|
||||
static internal InvalidOperationException ConfigProviderInvalid() {
|
||||
return InvalidOperation(Res.GetString(Res.ConfigProviderInvalid));
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
static internal ConfigurationException ConfigProviderNotInstalled() {
|
||||
return Configuration(Res.GetString(Res.ConfigProviderNotInstalled));
|
||||
}
|
||||
static internal ConfigurationException ConfigProviderMissing() {
|
||||
return Configuration(Res.GetString(Res.ConfigProviderMissing));
|
||||
}
|
||||
|
||||
//
|
||||
// DbProviderConfigurationHandler
|
||||
//
|
||||
static internal ConfigurationException ConfigBaseNoChildNodes(XmlNode node) { // Res.Config_base_no_child_nodes
|
||||
return Configuration(Res.GetString(Res.ConfigBaseNoChildNodes), node);
|
||||
}
|
||||
static internal ConfigurationException ConfigBaseElementsOnly(XmlNode node) { // Res.Config_base_elements_only
|
||||
return Configuration(Res.GetString(Res.ConfigBaseElementsOnly), node);
|
||||
}
|
||||
static internal ConfigurationException ConfigUnrecognizedAttributes(XmlNode node) { // Res.Config_base_unrecognized_attribute
|
||||
return Configuration(Res.GetString(Res.ConfigUnrecognizedAttributes, node.Attributes[0].Name), node);
|
||||
}
|
||||
static internal ConfigurationException ConfigUnrecognizedElement(XmlNode node) { // Res.Config_base_unrecognized_element
|
||||
return Configuration(Res.GetString(Res.ConfigUnrecognizedElement), node);
|
||||
}
|
||||
static internal ConfigurationException ConfigSectionsUnique(string sectionName) { // Res.Res.ConfigSectionsUnique
|
||||
return Configuration(Res.GetString(Res.ConfigSectionsUnique, sectionName));
|
||||
}
|
||||
static internal ConfigurationException ConfigRequiredAttributeMissing(string name, XmlNode node) { // Res.Config_base_required_attribute_missing
|
||||
return Configuration(Res.GetString(Res.ConfigRequiredAttributeMissing, name), node);
|
||||
}
|
||||
static internal ConfigurationException ConfigRequiredAttributeEmpty(string name, XmlNode node) { // Res.Config_base_required_attribute_empty
|
||||
return Configuration(Res.GetString(Res.ConfigRequiredAttributeEmpty, name), node);
|
||||
}
|
||||
#endif
|
||||
static internal Exception OleDb() => new NotImplementedException("OleDb is not implemented.");
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
// 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.Diagnostics;
|
||||
using System.Data.SqlClient;
|
||||
using System.Reflection;
|
||||
|
||||
namespace System.Data.Common
|
||||
{
|
||||
partial class DbConnectionStringDefaults
|
||||
{
|
||||
internal const string Dsn = "";
|
||||
internal const string Driver = "";
|
||||
}
|
||||
|
||||
partial class DbConnectionStringKeywords
|
||||
{
|
||||
internal const string Dsn = "Dsn";
|
||||
}
|
||||
}
|
18
mcs/class/System.Data/corefx/Odbc/OdbcFactory.cs
Normal file
18
mcs/class/System.Data/corefx/Odbc/OdbcFactory.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
// 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;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
|
||||
namespace System.Data.Odbc
|
||||
{
|
||||
partial class OdbcFactory
|
||||
{
|
||||
public override CodeAccessPermission CreatePermission(PermissionState state) =>
|
||||
new OdbcPermission(state);
|
||||
}
|
||||
}
|
45
mcs/class/System.Data/corefx/Odbc/Res.cs
Normal file
45
mcs/class/System.Data/corefx/Odbc/Res.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
// 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;
|
||||
|
||||
// needed for ../referencesource/System.Data/System/Data/CodeGen/datacache.cs
|
||||
internal static partial class Res
|
||||
{
|
||||
internal static string GetString(string name) => name;
|
||||
internal static string GetString(string name, params object[] args) => string.Format(name, args);
|
||||
|
||||
internal const string CodeGen_InvalidIdentifier = "Cannot generate identifier for name '{0}'";
|
||||
internal const string CodeGen_DuplicateTableName = "There is more than one table with the same name '{0}' (even if namespace is different)";
|
||||
internal const string CodeGen_TypeCantBeNull = "Column '{0}': Type '{1}' cannot be null";
|
||||
internal const string CodeGen_NoCtor0 = "Column '{0}': Type '{1}' does not have parameterless constructor";
|
||||
internal const string CodeGen_NoCtor1 = "Column '{0}': Type '{1}' does not have constructor with string argument";
|
||||
|
||||
internal const string SQLUDT_MaxByteSizeValue = "range: 0-8000";
|
||||
internal const string SqlUdt_InvalidUdtMessage = "'{0}' is an invalid user defined type, reason: {1}.";
|
||||
internal const string Sql_NullCommandText = "Command parameter must have a non null and non empty command text.";
|
||||
internal const string Sql_MismatchedMetaDataDirectionArrayLengths = "MetaData parameter array must have length equivalent to ParameterDirection array argument.";
|
||||
|
||||
public const string ADP_InvalidXMLBadVersion = "Invalid Xml; can only parse elements of version one.";
|
||||
public const string ADP_NotAPermissionElement = "Given security element is not a permission element.";
|
||||
public const string ADP_PermissionTypeMismatch = "Type mismatch.";
|
||||
|
||||
public const string ConfigProviderNotFound = "Unable to find the requested .Net Framework Data Provider. It may not be installed.";
|
||||
public const string ConfigProviderInvalid = "The requested .Net Framework Data Provider's implementation does not have an Instance field of a System.Data.Common.DbProviderFactory derived type.";
|
||||
public const string ConfigProviderNotInstalled = "Failed to find or load the registered .Net Framework Data Provider.";
|
||||
public const string ConfigProviderMissing = "The missing .Net Framework Data Provider's assembly qualified name is required.";
|
||||
public const string ConfigBaseElementsOnly = "Only elements allowed.";
|
||||
public const string ConfigBaseNoChildNodes = "Child nodes not allowed.";
|
||||
public const string ConfigUnrecognizedAttributes = "Unrecognized attribute '{0}'.";
|
||||
public const string ConfigUnrecognizedElement = "Unrecognized element.";
|
||||
public const string ConfigSectionsUnique = "The '{0}' section can only appear once per config file.";
|
||||
public const string ConfigRequiredAttributeMissing = "Required attribute '{0}' not found.";
|
||||
public const string ConfigRequiredAttributeEmpty = "Required attribute '{0}' cannot be empty.";
|
||||
public const string ADP_QuotePrefixNotSet = "{0} requires open connection when the quote prefix has not been set.";
|
||||
}
|
||||
|
||||
internal static partial class SR
|
||||
{
|
||||
public static string GetResourceString(string resourceKey, string defaultString) => defaultString;
|
||||
}
|
Reference in New Issue
Block a user