private static int GetKeyValuePair( string connectionString, int currentPosition, StringBuilder buffer, out string keyname, out string keyvalue) { int num = currentPosition; buffer.Length = 0; keyname = (string)null; keyvalue = (string)null; char minValue = char.MinValue; DbConnectionOptions.ParserState parserState = DbConnectionOptions.ParserState.NothingYet; for (int length = connectionString.Length; currentPosition < length; ++currentPosition) { minValue = connectionString[currentPosition]; switch (parserState) { case DbConnectionOptions.ParserState.NothingYet: if (';' != minValue && !char.IsWhiteSpace(minValue)) { if (minValue == char.MinValue) { parserState = DbConnectionOptions.ParserState.NullTermination; continue; } if (char.IsControl(minValue)) { throw new ArgumentException(Strings.ADP_ConnectionStringSyntax((object)num)); } num = currentPosition; if ('=' != minValue) { parserState = DbConnectionOptions.ParserState.Key; break; } parserState = DbConnectionOptions.ParserState.KeyEqual; continue; } continue; case DbConnectionOptions.ParserState.Key: if ('=' == minValue) { parserState = DbConnectionOptions.ParserState.KeyEqual; continue; } if (!char.IsWhiteSpace(minValue) && char.IsControl(minValue)) { throw new ArgumentException(Strings.ADP_ConnectionStringSyntax((object)num)); } break; case DbConnectionOptions.ParserState.KeyEqual: if ('=' == minValue) { parserState = DbConnectionOptions.ParserState.Key; break; } keyname = DbConnectionOptions.GetKeyName(buffer); if (string.IsNullOrEmpty(keyname)) { throw new ArgumentException(Strings.ADP_ConnectionStringSyntax((object)num)); } buffer.Length = 0; parserState = DbConnectionOptions.ParserState.KeyEnd; goto case DbConnectionOptions.ParserState.KeyEnd; case DbConnectionOptions.ParserState.KeyEnd: if (!char.IsWhiteSpace(minValue)) { if ('\'' == minValue) { parserState = DbConnectionOptions.ParserState.SingleQuoteValue; continue; } if ('"' == minValue) { parserState = DbConnectionOptions.ParserState.DoubleQuoteValue; continue; } if (';' != minValue && minValue != char.MinValue) { if (char.IsControl(minValue)) { throw new ArgumentException(Strings.ADP_ConnectionStringSyntax((object)num)); } parserState = DbConnectionOptions.ParserState.UnquotedValue; break; } goto label_54; } else { continue; } case DbConnectionOptions.ParserState.UnquotedValue: if (char.IsWhiteSpace(minValue) || !char.IsControl(minValue) && ';' != minValue) { break; } goto label_54; case DbConnectionOptions.ParserState.DoubleQuoteValue: if ('"' == minValue) { parserState = DbConnectionOptions.ParserState.DoubleQuoteValueQuote; continue; } if (minValue == char.MinValue) { throw new ArgumentException(Strings.ADP_ConnectionStringSyntax((object)num)); } break; case DbConnectionOptions.ParserState.DoubleQuoteValueQuote: if ('"' == minValue) { parserState = DbConnectionOptions.ParserState.DoubleQuoteValue; break; } keyvalue = DbConnectionOptions.GetKeyValue(buffer, false); parserState = DbConnectionOptions.ParserState.QuotedValueEnd; goto case DbConnectionOptions.ParserState.QuotedValueEnd; case DbConnectionOptions.ParserState.SingleQuoteValue: if ('\'' == minValue) { parserState = DbConnectionOptions.ParserState.SingleQuoteValueQuote; continue; } if (minValue == char.MinValue) { throw new ArgumentException(Strings.ADP_ConnectionStringSyntax((object)num)); } break; case DbConnectionOptions.ParserState.SingleQuoteValueQuote: if ('\'' == minValue) { parserState = DbConnectionOptions.ParserState.SingleQuoteValue; break; } keyvalue = DbConnectionOptions.GetKeyValue(buffer, false); parserState = DbConnectionOptions.ParserState.QuotedValueEnd; goto case DbConnectionOptions.ParserState.QuotedValueEnd; case DbConnectionOptions.ParserState.QuotedValueEnd: if (!char.IsWhiteSpace(minValue)) { if (';' != minValue) { if (minValue != char.MinValue) { throw new ArgumentException(Strings.ADP_ConnectionStringSyntax((object)num)); } parserState = DbConnectionOptions.ParserState.NullTermination; continue; } goto label_54; } else { continue; } case DbConnectionOptions.ParserState.NullTermination: if (minValue != char.MinValue && !char.IsWhiteSpace(minValue)) { throw new ArgumentException(Strings.ADP_ConnectionStringSyntax((object)currentPosition)); } continue; default: throw new InvalidOperationException(Strings.ADP_InternalProviderError((object)1015)); } buffer.Append(minValue); } label_54: switch (parserState) { case DbConnectionOptions.ParserState.NothingYet: case DbConnectionOptions.ParserState.KeyEnd: case DbConnectionOptions.ParserState.NullTermination: if (';' == minValue && currentPosition < connectionString.Length) { ++currentPosition; } return(currentPosition); case DbConnectionOptions.ParserState.Key: case DbConnectionOptions.ParserState.DoubleQuoteValue: case DbConnectionOptions.ParserState.SingleQuoteValue: throw new ArgumentException(Strings.ADP_ConnectionStringSyntax((object)num)); case DbConnectionOptions.ParserState.KeyEqual: keyname = DbConnectionOptions.GetKeyName(buffer); if (string.IsNullOrEmpty(keyname)) { throw new ArgumentException(Strings.ADP_ConnectionStringSyntax((object)num)); } goto case DbConnectionOptions.ParserState.NothingYet; case DbConnectionOptions.ParserState.UnquotedValue: keyvalue = DbConnectionOptions.GetKeyValue(buffer, true); char ch = keyvalue[keyvalue.Length - 1]; if ('\'' == ch || '"' == ch) { throw new ArgumentException(Strings.ADP_ConnectionStringSyntax((object)num)); } goto case DbConnectionOptions.ParserState.NothingYet; case DbConnectionOptions.ParserState.DoubleQuoteValueQuote: case DbConnectionOptions.ParserState.SingleQuoteValueQuote: case DbConnectionOptions.ParserState.QuotedValueEnd: keyvalue = DbConnectionOptions.GetKeyValue(buffer, false); goto case DbConnectionOptions.ParserState.NothingYet; default: throw new InvalidOperationException(Strings.ADP_InternalProviderError((object)1016)); } }