static private CheckArgumentNull ( object value, string parameterName ) : void | ||
value | object | |
parameterName | string | |
Résultat | void |
public virtual bool Remove(string keyword) { Bid.Trace("<comm.DbConnectionStringBuilder.Remove|API> %d#, keyword='%ls'\n", ObjectID, keyword); ADP.CheckArgumentNull(keyword, "keyword"); if (CurrentValues.Remove(keyword)) { _connectionString = null; _propertyDescriptors = null; return(true); } return(false); }
public virtual bool Remove(string keyword) { DataCommonEventSource.Log.Trace("<comm.DbConnectionStringBuilder.Remove|API> {0}, keyword='{1}'", ObjectID, keyword); ADP.CheckArgumentNull(keyword, nameof(keyword)); if (CurrentValues.Remove(keyword)) { _connectionString = null; _propertyDescriptors = null; return(true); } return(false); }
public static DbProviderFactory GetFactory(DbConnection connection) { ADP.CheckArgumentNull(connection, nameof(connection)); var property = typeof(DbConnection).GetProperty("DbProviderFactory", BindingFlags.NonPublic | BindingFlags.Instance); var value = property.GetValue(connection); return((DbProviderFactory)value); //return connection.ProviderFactory; }
static public DbProviderFactory GetFactory(DataRow providerRow) { ADP.CheckArgumentNull(providerRow, "providerRow"); // fail with ConfigProviderMissing rather than ColumnNotInTheTable exception DataColumn column = providerRow.Table.Columns[AssemblyQualifiedName]; if (null != column) { // column value may not be a string string assemblyQualifiedName = providerRow[column] as string; if (!ADP.IsEmpty(assemblyQualifiedName)) { // FXCop is concerned about the following line call to Get Type, // If this code is deemed safe during our security review we should add this warning to our exclusion list. // FXCop Message, pertaining to the call to GetType. // // Secure late-binding methods,System.Data.dll!System.Data.Common.DbProviderFactories.GetFactory(System.Data.DataRow):System.Data.Common.DbProviderFactory, Type providerType = Type.GetType(assemblyQualifiedName); if (null != providerType) { System.Reflection.FieldInfo providerInstance = providerType.GetField(Instance, System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static); if (null != providerInstance) { Debug.Assert(providerInstance.IsPublic, "field not public"); Debug.Assert(providerInstance.IsStatic, "field not static"); if (providerInstance.FieldType.IsSubclassOf(typeof(DbProviderFactory))) { object factory = providerInstance.GetValue(null); if (null != factory) { return((DbProviderFactory)factory); } // else throw ConfigProviderInvalid } // else throw ConfigProviderInvalid } throw ADP.ConfigProviderInvalid(); } throw ADP.ConfigProviderNotInstalled(); } // else throw ConfigProviderMissing } throw ADP.ConfigProviderMissing(); }
public virtual bool EquivalentTo(DbConnectionStringBuilder connectionStringBuilder) { ADP.CheckArgumentNull(connectionStringBuilder, "connectionStringBuilder"); Bid.Trace("<comm.DbConnectionStringBuilder.EquivalentTo|API> %d#, connectionStringBuilder=%d#\n", this.ObjectID, connectionStringBuilder.ObjectID); if ((base.GetType() != connectionStringBuilder.GetType()) || (this.CurrentValues.Count != connectionStringBuilder.CurrentValues.Count)) { return(false); } foreach (KeyValuePair <string, object> pair in this.CurrentValues) { object obj2; if (!connectionStringBuilder.CurrentValues.TryGetValue(pair.Key, out obj2) || !pair.Value.Equals(obj2)) { return(false); } } return(true); }
public static DbProviderFactory GetFactory(DataRow providerRow) { ADP.CheckArgumentNull(providerRow, nameof(providerRow)); DataColumn?assemblyQualifiedNameColumn = providerRow.Table.Columns[AssemblyQualifiedNameColumnName]; if (null == assemblyQualifiedNameColumn) { throw ADP.Argument(SR.ADP_DbProviderFactories_NoAssemblyQualifiedName); } string?assemblyQualifiedName = providerRow[assemblyQualifiedNameColumn] as string; if (string.IsNullOrWhiteSpace(assemblyQualifiedName)) { throw ADP.Argument(SR.ADP_DbProviderFactories_NoAssemblyQualifiedName); } return(GetFactoryInstance(GetProviderTypeFromTypeName(assemblyQualifiedName))); }
public virtual bool EquivalentTo(DbConnectionStringBuilder connectionStringBuilder) { ADP.CheckArgumentNull(connectionStringBuilder, nameof(connectionStringBuilder)); DataCommonEventSource.Log.Trace("<comm.DbConnectionStringBuilder.EquivalentTo|API> {0}, connectionStringBuilder={1}", ObjectID, connectionStringBuilder.ObjectID); if ((GetType() != connectionStringBuilder.GetType()) || (CurrentValues.Count != connectionStringBuilder.CurrentValues.Count)) { return(false); } object?value; foreach (KeyValuePair <string, object> entry in CurrentValues) { if (!connectionStringBuilder.CurrentValues.TryGetValue(entry.Key, out value) || !entry.Value.Equals(value)) { return(false); } } return(true); }
public virtual bool EquivalentTo(DbConnectionStringBuilder connectionStringBuilder) { ADP.CheckArgumentNull(connectionStringBuilder, "connectionStringBuilder"); if ((GetType() != connectionStringBuilder.GetType()) || (CurrentValues.Count != connectionStringBuilder.CurrentValues.Count)) { return(false); } object value; foreach (KeyValuePair <string, object> entry in CurrentValues) { if (!connectionStringBuilder.CurrentValues.TryGetValue(entry.Key, out value) || !entry.Value.Equals(value)) { return(false); } } return(true); }
public RowUpdatingEventArgs(DataRow dataRow, IDbCommand command, System.Data.StatementType statementType, DataTableMapping tableMapping) { ADP.CheckArgumentNull(dataRow, "dataRow"); ADP.CheckArgumentNull(tableMapping, "tableMapping"); switch (statementType) { case System.Data.StatementType.Select: case System.Data.StatementType.Insert: case System.Data.StatementType.Update: case System.Data.StatementType.Delete: this._dataRow = dataRow; this._command = command; this._statementType = statementType; this._tableMapping = tableMapping; return; case System.Data.StatementType.Batch: throw ADP.NotSupportedStatementType(statementType, "RowUpdatingEventArgs"); } throw ADP.InvalidStatementType(statementType); }
public virtual object this[string keyword] { get { DataCommonEventSource.Log.Trace("<comm.DbConnectionStringBuilder.get_Item|API> {0}, keyword='{1}'", ObjectID, keyword); ADP.CheckArgumentNull(keyword, nameof(keyword)); object value; if (CurrentValues.TryGetValue(keyword, out value)) { return(value); } throw ADP.KeywordNotSupported(keyword); } set { ADP.CheckArgumentNull(keyword, nameof(keyword)); bool flag = false; if (null != value) { string keyvalue = DbConnectionStringBuilderUtil.ConvertToString(value); DbConnectionOptions.ValidateKeyValuePair(keyword, keyvalue); flag = CurrentValues.ContainsKey(keyword); // store keyword/value pair CurrentValues[keyword] = keyvalue; } else { flag = Remove(keyword); } _connectionString = null; if (flag) { _propertyDescriptors = null; } } }
private UpdateStatus _status; // UpdateStatus.Continue; /*0*/ public RowUpdatingEventArgs(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) { ADP.CheckArgumentNull(dataRow, "dataRow"); ADP.CheckArgumentNull(tableMapping, "tableMapping"); switch (statementType) { case StatementType.Select: case StatementType.Insert: case StatementType.Update: case StatementType.Delete: break; case StatementType.Batch: throw ADP.NotSupportedStatementType(statementType, "RowUpdatingEventArgs"); default: throw ADP.InvalidStatementType(statementType); } _dataRow = dataRow; _command = command; // maybe null _statementType = statementType; _tableMapping = tableMapping; }
public static DbProviderFactory?GetFactory(DbConnection connection) { ADP.CheckArgumentNull(connection, nameof(connection)); return(connection.ProviderFactory); }
public virtual bool TryGetValue(string keyword, out object value) { ADP.CheckArgumentNull(keyword, nameof(keyword)); return(CurrentValues.TryGetValue(keyword, out value)); }
// does the keyword exist as a stored value or something that should always be persisted public virtual bool ShouldSerialize(string keyword) { ADP.CheckArgumentNull(keyword, nameof(keyword)); return(CurrentValues.ContainsKey(keyword)); }
static public DbProviderFactory GetFactory(DbConnection connection) { ADP.CheckArgumentNull(connection, "connection"); return(connection.ProviderFactory); }
public virtual bool ContainsKey(string keyword) { ADP.CheckArgumentNull(keyword, "keyword"); return(CurrentValues.ContainsKey(keyword)); }
internal static void AppendKeyValuePairBuilder(StringBuilder builder, string keyName, string keyValue, bool useOdbcRules) { ADP.CheckArgumentNull(builder, nameof(builder)); ADP.CheckArgumentLength(keyName, nameof(keyName)); if ((null == keyName) || !s_connectionStringValidKeyRegex.IsMatch(keyName)) { throw ADP.InvalidKeyname(keyName); } if ((null != keyValue) && !IsValueValidInternal(keyValue)) { throw ADP.InvalidValue(keyName); } if ((0 < builder.Length) && (';' != builder[builder.Length - 1])) { builder.Append(';'); } if (useOdbcRules) { builder.Append(keyName); } else { builder.Append(keyName.Replace("=", "==")); } builder.Append('='); if (null != keyValue) { // else <keyword>=; if (useOdbcRules) { if ((0 < keyValue.Length) && // string.Contains(char) is .NetCore2.1+ specific (('{' == keyValue[0]) || (0 <= keyValue.IndexOf(';')) || string.Equals(DbConnectionStringKeywords.Driver, keyName, StringComparison.OrdinalIgnoreCase)) && !s_connectionStringQuoteOdbcValueRegex.IsMatch(keyValue)) { // always quote Driver value (required for ODBC Version 2.65 and earlier) // always quote values that contain a ';' builder.Append('{').Append(keyValue.Replace("}", "}}")).Append('}'); } else { builder.Append(keyValue); } } else if (s_connectionStringQuoteValueRegex.IsMatch(keyValue)) { // <value> -> <value> builder.Append(keyValue); } // string.Contains(char) is .NetCore2.1+ specific else if ((-1 != keyValue.IndexOf('\"')) && (-1 == keyValue.IndexOf('\''))) { // <val"ue> -> <'val"ue'> builder.Append('\''); builder.Append(keyValue); builder.Append('\''); } else { // <val'ue> -> <"val'ue"> // <=value> -> <"=value"> // <;value> -> <";value"> // < value> -> <" value"> // <va lue> -> <"va lue"> // <va'"lue> -> <"va'""lue"> builder.Append('\"'); builder.Append(keyValue.Replace("\"", "\"\"")); builder.Append('\"'); } } }
public virtual bool ShouldSerialize(string keyword) { Bid.Trace("<comm.DbConnectionStringBuilder.ShouldSerialize|API> keyword='%ls'\n", keyword); ADP.CheckArgumentNull(keyword, "keyword"); return(this.CurrentValues.ContainsKey(keyword)); }