static private KeywordNotSupported ( string keyword ) : |
||
keyword | string | |
return |
private static string[] ParseRestrictions(string restrictions, Dictionary <string, string> synonyms) { List <string> restrictionValues = new List <string>(); StringBuilder buffer = new StringBuilder(restrictions.Length); int nextStartPosition = 0; int endPosition = restrictions.Length; while (nextStartPosition < endPosition) { int startPosition = nextStartPosition; string keyname, keyvalue; // since parsing restrictions ignores values, it doesn't matter if we use ODBC rules or OLEDB rules nextStartPosition = DbConnectionOptions.GetKeyValuePair(restrictions, startPosition, buffer, false, out keyname, out keyvalue); if (!string.IsNullOrEmpty(keyname)) { string realkeyname = ((null != synonyms) ? (string)synonyms[keyname] : keyname); // MDAC 85144 if (string.IsNullOrEmpty(realkeyname)) { throw ADP.KeywordNotSupported(keyname); } restrictionValues.Add(realkeyname); } } return(RemoveDuplicates(restrictionValues.ToArray())); }
private static string[] ParseRestrictions(string restrictions, Hashtable synonyms) { #if DEBUG DataCommonEventSource.Log.Trace("<comm.DBConnectionString|INFO|ADV> Restrictions='{0}'", restrictions); #endif List <string> restrictionValues = new List <string>(); StringBuilder buffer = new StringBuilder(restrictions.Length); int nextStartPosition = 0; int endPosition = restrictions.Length; while (nextStartPosition < endPosition) { int startPosition = nextStartPosition; string keyname, keyvalue; // since parsing restrictions ignores values, it doesn't matter if we use ODBC rules or OLEDB rules nextStartPosition = DbConnectionOptions.GetKeyValuePair(restrictions, startPosition, buffer, false, out keyname, out keyvalue); if (!string.IsNullOrEmpty(keyname)) { #if DEBUG DataCommonEventSource.Log.Trace("<comm.DBConnectionString|INFO|ADV> KeyName='{0}'", keyname); #endif string realkeyname = ((null != synonyms) ? (string)synonyms[keyname] : keyname); if (string.IsNullOrEmpty(realkeyname)) { throw ADP.KeywordNotSupported(keyname); } restrictionValues.Add(realkeyname); } } return(RemoveDuplicates(restrictionValues.ToArray())); }
private static NameValuePair ParseInternal(Hashtable parsetable, string connectionString, bool buildChain, Hashtable synonyms, bool firstKey) { Debug.Assert(null != connectionString, "null connectionstring"); StringBuilder buffer = new StringBuilder(); NameValuePair localKeychain = null, keychain = null; #if DEBUG try { #endif int nextStartPosition = 0; int endPosition = connectionString.Length; while (nextStartPosition < endPosition) { int startPosition = nextStartPosition; string keyname, keyvalue; nextStartPosition = GetKeyValuePair(connectionString, startPosition, buffer, firstKey, out keyname, out keyvalue); if (ADP.IsEmpty(keyname)) { // if (nextStartPosition != endPosition) { throw; } break; } #if DEBUG DebugTraceKeyValuePair(keyname, keyvalue, synonyms); Debug.Assert(IsKeyNameValid(keyname), "ParseFailure, invalid keyname"); Debug.Assert(IsValueValidInternal(keyvalue), "parse failure, invalid keyvalue"); #endif string realkeyname = ((null != synonyms) ? (string)synonyms[keyname] : keyname); if (!IsKeyNameValid(realkeyname)) { throw ADP.KeywordNotSupported(keyname); } if (!firstKey || !parsetable.Contains(realkeyname)) { parsetable[realkeyname] = keyvalue; // last key-value pair wins (or first) } if (null != localKeychain) { localKeychain = localKeychain.Next = new NameValuePair(realkeyname, keyvalue, nextStartPosition - startPosition); } else if (buildChain) { // first time only - don't contain modified chain from UDL file keychain = localKeychain = new NameValuePair(realkeyname, keyvalue, nextStartPosition - startPosition); } } #if DEBUG } catch (ArgumentException e) { ParseComparison(parsetable, connectionString, synonyms, firstKey, e); throw; } ParseComparison(parsetable, connectionString, synonyms, firstKey, null); #endif return(keychain); }
public virtual object this[string keyword] { get { Bid.Trace("<comm.DbConnectionStringBuilder.get_Item|API> %d#, keyword='%ls'\n", ObjectID, keyword); ADP.CheckArgumentNull(keyword, "keyword"); object value; if (CurrentValues.TryGetValue(keyword, out value)) { return(value); } throw ADP.KeywordNotSupported(keyword); } set { ADP.CheckArgumentNull(keyword, "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; } } }
public virtual object this[string keyword] { get { ADP.CheckArgumentNull(keyword, "keyword"); object value; if (CurrentValues.TryGetValue(keyword, out value)) { return(value); } throw ADP.KeywordNotSupported(keyword); } set { ADP.CheckArgumentNull(keyword, "keyword"); if (null != value) { string keyvalue = DbConnectionStringBuilderUtil.ConvertToString(value); DbConnectionOptions.ValidateKeyValuePair(keyword, keyvalue); // store keyword/value pair CurrentValues[keyword] = keyvalue; } _connectionString = null; } }
private static Dictionary<string, string> SplitConnectionString(string connectionString, Dictionary<string, string> synonyms, bool firstKey) { var parsetable = new Dictionary<string, string>(); Regex parser = (firstKey ? s_connectionStringRegexOdbc : s_connectionStringRegex); const int KeyIndex = 1, ValueIndex = 2; Debug.Assert(KeyIndex == parser.GroupNumberFromName("key"), "wrong key index"); Debug.Assert(ValueIndex == parser.GroupNumberFromName("value"), "wrong value index"); if (null != connectionString) { Match match = parser.Match(connectionString); if (!match.Success || (match.Length != connectionString.Length)) { throw ADP.ConnectionStringSyntax(match.Length); } int indexValue = 0; CaptureCollection keyvalues = match.Groups[ValueIndex].Captures; foreach (Capture keypair in match.Groups[KeyIndex].Captures) { string keyname = (firstKey ? keypair.Value : keypair.Value.Replace("==", "=")).ToLower(CultureInfo.InvariantCulture); string keyvalue = keyvalues[indexValue++].Value; if (0 < keyvalue.Length) { if (!firstKey) { switch (keyvalue[0]) { case '\"': keyvalue = keyvalue.Substring(1, keyvalue.Length - 2).Replace("\"\"", "\""); break; case '\'': keyvalue = keyvalue.Substring(1, keyvalue.Length - 2).Replace("\'\'", "\'"); break; default: break; } } } else { keyvalue = null; } DebugTraceKeyValuePair(keyname, keyvalue, synonyms); string synonym; string realkeyname = null != synonyms ? (synonyms.TryGetValue(keyname, out synonym) ? synonym : null) : keyname; if (!IsKeyNameValid(realkeyname)) { throw ADP.KeywordNotSupported(keyname); } if (!firstKey || !parsetable.ContainsKey(realkeyname)) { parsetable[realkeyname] = keyvalue; // last key-value pair wins (or first) } } } return parsetable; }
private static string[] ParseRestrictions(string restrictions, Hashtable synonyms) { List <string> list = new List <string>(); StringBuilder buffer = new StringBuilder(restrictions.Length); int num = 0; int length = restrictions.Length; while (num < length) { string str; string str3; int currentPosition = num; num = DbConnectionOptions.GetKeyValuePair(restrictions, currentPosition, buffer, false, out str, out str3); if (!ADP.IsEmpty(str)) { string str2 = (synonyms != null) ? ((string)synonyms[str]) : str; if (ADP.IsEmpty(str2)) { throw ADP.KeywordNotSupported(str); } list.Add(str2); } } return(RemoveDuplicates(list.ToArray())); }
public virtual object this[string keyword] { get { object obj2; Bid.Trace("<comm.DbConnectionStringBuilder.get_Item|API> %d#, keyword='%ls'\n", this.ObjectID, keyword); ADP.CheckArgumentNull(keyword, "keyword"); if (!this.CurrentValues.TryGetValue(keyword, out obj2)) { throw ADP.KeywordNotSupported(keyword); } return(obj2); } set { ADP.CheckArgumentNull(keyword, "keyword"); bool flag = false; if (value != null) { string str = DbConnectionStringBuilderUtil.ConvertToString(value); DbConnectionOptions.ValidateKeyValuePair(keyword, str); flag = this.CurrentValues.ContainsKey(keyword); this.CurrentValues[keyword] = str; } else { flag = this.Remove(keyword); } this._connectionString = null; if (flag) { this._propertyDescriptors = null; } } }
private static Hashtable SplitConnectionString(string connectionString, Hashtable synonyms) { Hashtable parsetable = new Hashtable(); Regex parser = s_connectionStringRegex; const int KeyIndex = 1, ValueIndex = 2; Debug.Assert(KeyIndex == parser.GroupNumberFromName("key"), "wrong key index"); Debug.Assert(ValueIndex == parser.GroupNumberFromName("value"), "wrong value index"); if (null != connectionString) { Match match = parser.Match(connectionString); if (!match.Success || (match.Length != connectionString.Length)) { throw ADP.ConnectionStringSyntax(match.Length); } int indexValue = 0; CaptureCollection keyvalues = match.Groups[ValueIndex].Captures; foreach (Capture keypair in match.Groups[KeyIndex].Captures) { string keyname = keypair.Value.Replace("==", "=").ToLowerInvariant(); string keyvalue = keyvalues[indexValue++].Value; if (0 < keyvalue.Length) { { switch (keyvalue[0]) { case '\"': keyvalue = keyvalue.Substring(1, keyvalue.Length - 2).Replace("\"\"", "\""); break; case '\'': keyvalue = keyvalue.Substring(1, keyvalue.Length - 2).Replace("\'\'", "\'"); break; default: break; } } } else { keyvalue = null; } DebugTraceKeyValuePair(keyname, keyvalue, synonyms); string realkeyname = ((null != synonyms) ? (string)synonyms[keyname] : keyname); if (!IsKeyNameValid(realkeyname)) { throw ADP.KeywordNotSupported(keyname); } { parsetable[realkeyname] = keyvalue; // last key-value pair wins (or first) } } } return(parsetable); }
private static NameValuePair ParseInternal(Hashtable parsetable, string connectionString, bool buildChain, Hashtable synonyms, bool firstKey) { StringBuilder buffer = new StringBuilder(); NameValuePair pair = null; NameValuePair pair2 = null; int num = 0; int length = connectionString.Length; while (num < length) { string str2; string str3; int currentPosition = num; num = GetKeyValuePair(connectionString, currentPosition, buffer, firstKey, out str2, out str3); if (ADP.IsEmpty(str2)) { return(pair2); } string keyname = (synonyms != null) ? ((string)synonyms[str2]) : str2; if (!IsKeyNameValid(keyname)) { throw ADP.KeywordNotSupported(str2); } if (!firstKey || !parsetable.Contains(keyname)) { parsetable[keyname] = str3; } if (pair != null) { pair = pair.Next = new NameValuePair(keyname, str3, num - currentPosition); } else if (buildChain) { pair2 = pair = new NameValuePair(keyname, str3, num - currentPosition); } } return(pair2); }