Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- internal static int GetKeyValuePair(string connectionString, int currentPosition, StringBuilder buffer, bool useOdbcRules, out string keyname, out string keyvalue)
- {
- char chr;
- int num = currentPosition;
- buffer.Length = 0;
- keyname = null;
- keyvalue = null;
- ParserState parserState = ParserState.NothingYet;
- int length = connectionString.Length;
- Label8:
- while (currentPosition < length)
- {
- chr = connectionString[currentPosition];
- ParserState parserState1 = parserState;
- if (parserState1 == ParserState.NothingYet)
- {
- if (59 == chr || char.IsWhiteSpace(chr))
- {
- goto Label2;
- }
- if (chr != 0)
- {
- if (!char.IsControl(chr))
- {
- num = currentPosition;
- if (61 == chr)
- {
- parserState = ParserState.KeyEqual;
- goto Label2;
- }
- else
- {
- parserState = ParserState.Key;
- }
- }
- else
- {
- throw ADP.ConnectionStringSyntax(num);
- }
- }
- else
- {
- parserState = ParserState.NullTermination;
- goto Label2;
- }
- }
- else if (parserState1 == ParserState.Key)
- {
- if (61 != chr)
- {
- if (char.IsWhiteSpace(chr) || !char.IsControl(chr))
- {
- goto Label4;
- }
- throw ADP.ConnectionStringSyntax(num);
- }
- else
- {
- parserState = ParserState.KeyEqual;
- goto Label2;
- }
- }
- else if (parserState1 == ParserState.KeyEqual)
- {
- if (useOdbcRules || 61 != chr)
- {
- keyname = DbConnectionOptions.GetKeyName(buffer);
- if (!ADP.IsEmpty(ref keyname))
- {
- buffer.Length = 0;
- parserState = ParserState.KeyEnd;
- goto Label0;
- }
- else
- {
- throw ADP.ConnectionStringSyntax(num);
- }
- }
- else
- {
- parserState = ParserState.Key;
- }
- }
- else if (parserState1 == ParserState.KeyEnd)
- {
- goto Label0;
- }
- else if (parserState1 == ParserState.UnquotedValue)
- {
- if (char.IsWhiteSpace(chr))
- {
- goto Label4;
- }
- if (char.IsControl(chr))
- {
- break;
- }
- if (59 != chr)
- {
- goto Label4;
- }
- break;
- }
- else if (parserState1 == ParserState.DoubleQuoteValue)
- {
- if (34 != chr)
- {
- if (chr != 0)
- {
- goto Label4;
- }
- throw ADP.ConnectionStringSyntax(num);
- }
- else
- {
- parserState = ParserState.DoubleQuoteValueQuote;
- goto Label2;
- }
- }
- else if (parserState1 == ParserState.DoubleQuoteValueQuote)
- {
- if (34 != chr)
- {
- keyvalue = DbConnectionOptions.GetKeyValue(buffer, false);
- parserState = ParserState.QuotedValueEnd;
- goto Label1;
- }
- else
- {
- parserState = ParserState.DoubleQuoteValue;
- }
- }
- else if (parserState1 == ParserState.SingleQuoteValue)
- {
- if (39 != chr)
- {
- if (chr != 0)
- {
- goto Label4;
- }
- throw ADP.ConnectionStringSyntax(num);
- }
- else
- {
- parserState = ParserState.SingleQuoteValueQuote;
- goto Label2;
- }
- }
- else if (parserState1 == ParserState.SingleQuoteValueQuote)
- {
- if (39 != chr)
- {
- keyvalue = DbConnectionOptions.GetKeyValue(buffer, false);
- parserState = ParserState.QuotedValueEnd;
- goto Label1;
- }
- else
- {
- parserState = ParserState.SingleQuoteValue;
- }
- }
- else if (parserState1 == ParserState.BraceQuoteValue)
- {
- if (125 != chr)
- {
- if (chr != 0)
- {
- goto Label4;
- }
- throw ADP.ConnectionStringSyntax(num);
- }
- else
- {
- parserState = ParserState.BraceQuoteValueQuote;
- }
- }
- else if (parserState1 == ParserState.BraceQuoteValueQuote)
- {
- if (125 != chr)
- {
- keyvalue = DbConnectionOptions.GetKeyValue(buffer, false);
- parserState = ParserState.QuotedValueEnd;
- goto Label1;
- }
- else
- {
- parserState = ParserState.BraceQuoteValue;
- }
- }
- else if (parserState1 == ParserState.QuotedValueEnd)
- {
- goto Label1;
- }
- else if (parserState1 == ParserState.NullTermination)
- {
- if (chr == 0 || char.IsWhiteSpace(chr))
- {
- goto Label2;
- }
- throw ADP.ConnectionStringSyntax(currentPosition);
- }
- else
- {
- throw ADP.InternalError(InternalErrorCode.InvalidParserState1);
- }
- Label4:
- buffer.Append(chr);
- goto Label2;
- }
- ParserState parserState2 = parserState;
- switch (parserState2)
- {
- case ParserState.KeyEqual:
- case ParserState.DoubleQuoteValue:
- case ParserState.NothingYet | ParserState.Key | ParserState.KeyEqual | ParserState.KeyEnd | ParserState.UnquotedValue | ParserState.DoubleQuoteValue | ParserState.DoubleQuoteValueQuote | ParserState.SingleQuoteValue | ParserState.SingleQuoteValueQuote | ParserState.BraceQuoteValue | ParserState.BraceQuoteValueQuote | ParserState.QuotedValueEnd | ParserState.NullTermination:
- {
- if (59 == chr && currentPosition < connectionString.Length)
- {
- currentPosition++;
- }
- return currentPosition;
- }
- case ParserState.KeyEnd:
- case ParserState.SingleQuoteValue:
- case ParserState.BraceQuoteValue:
- case ParserState.QuotedValueEnd:
- {
- throw ADP.ConnectionStringSyntax(num);
- }
- case ParserState.UnquotedValue:
- {
- keyname = DbConnectionOptions.GetKeyName(buffer);
- if (!ADP.IsEmpty(ref keyname))
- {
- if (59 == chr && currentPosition < connectionString.Length)
- {
- currentPosition++;
- }
- return currentPosition;
- }
- throw ADP.ConnectionStringSyntax(num);
- }
- case ParserState.DoubleQuoteValueQuote:
- {
- keyvalue = DbConnectionOptions.GetKeyValue(buffer, true);
- char chars = keyvalue.Chars;
- if (useOdbcRules || 39 != chars && 34 != chars)
- {
- if (59 == chr && currentPosition < connectionString.Length)
- {
- currentPosition++;
- }
- return currentPosition;
- }
- throw ADP.ConnectionStringSyntax(num);
- }
- case ParserState.SingleQuoteValueQuote:
- case ParserState.BraceQuoteValueQuote:
- case ParserState.NullTermination:
- case ParserState.Key | ParserState.KeyEnd | ParserState.DoubleQuoteValue | ParserState.SingleQuoteValue | ParserState.BraceQuoteValue | ParserState.QuotedValueEnd:
- {
- keyvalue = DbConnectionOptions.GetKeyValue(buffer, false);
- if (59 == chr && currentPosition < connectionString.Length)
- {
- currentPosition++;
- }
- return currentPosition;
- }
- }
- throw ADP.InternalError(InternalErrorCode.InvalidParserState2);
- Label0:
- if (!char.IsWhiteSpace(chr))
- {
- if (!useOdbcRules)
- {
- if (39 != chr)
- {
- if (34 != chr)
- {
- goto Label7;
- }
- parserState = ParserState.DoubleQuoteValue;
- goto Label2;
- }
- else
- {
- parserState = ParserState.SingleQuoteValue;
- goto Label2;
- }
- }
- else
- {
- if (123 != chr)
- {
- goto Label7;
- }
- parserState = ParserState.BraceQuoteValue;
- goto Label4;
- }
- Label7:
- if (59 == chr || chr == 0)
- {
- parserState2 = parserState;
- switch (parserState2)
- {
- case ParserState.KeyEqual:
- case ParserState.DoubleQuoteValue:
- case ParserState.NothingYet | ParserState.Key | ParserState.KeyEqual | ParserState.KeyEnd | ParserState.UnquotedValue | ParserState.DoubleQuoteValue | ParserState.DoubleQuoteValueQuote | ParserState.SingleQuoteValue | ParserState.SingleQuoteValueQuote | ParserState.BraceQuoteValue | ParserState.BraceQuoteValueQuote | ParserState.QuotedValueEnd | ParserState.NullTermination:
- {
- if (59 == chr && currentPosition < connectionString.Length)
- {
- currentPosition++;
- }
- return currentPosition;
- }
- case ParserState.KeyEnd:
- case ParserState.SingleQuoteValue:
- case ParserState.BraceQuoteValue:
- case ParserState.QuotedValueEnd:
- {
- throw ADP.ConnectionStringSyntax(num);
- }
- case ParserState.UnquotedValue:
- {
- keyname = DbConnectionOptions.GetKeyName(buffer);
- if (!ADP.IsEmpty(ref keyname))
- {
- if (59 == chr && currentPosition < connectionString.Length)
- {
- currentPosition++;
- }
- return currentPosition;
- }
- throw ADP.ConnectionStringSyntax(num);
- }
- case ParserState.DoubleQuoteValueQuote:
- {
- keyvalue = DbConnectionOptions.GetKeyValue(buffer, true);
- char chars = keyvalue.Chars;
- if (useOdbcRules || 39 != chars && 34 != chars)
- {
- if (59 == chr && currentPosition < connectionString.Length)
- {
- currentPosition++;
- }
- return currentPosition;
- }
- throw ADP.ConnectionStringSyntax(num);
- }
- case ParserState.SingleQuoteValueQuote:
- case ParserState.BraceQuoteValueQuote:
- case ParserState.NullTermination:
- case ParserState.Key | ParserState.KeyEnd | ParserState.DoubleQuoteValue | ParserState.SingleQuoteValue | ParserState.BraceQuoteValue | ParserState.QuotedValueEnd:
- {
- keyvalue = DbConnectionOptions.GetKeyValue(buffer, false);
- if (59 == chr && currentPosition < connectionString.Length)
- {
- currentPosition++;
- }
- return currentPosition;
- }
- }
- throw ADP.InternalError(InternalErrorCode.InvalidParserState2);
- }
- if (!char.IsControl(chr))
- {
- parserState = ParserState.UnquotedValue;
- goto Label4;
- }
- else
- {
- throw ADP.ConnectionStringSyntax(num);
- }
- }
- Label2:
- currentPosition++;
- goto Label8;
- Label1:
- if (!char.IsWhiteSpace(chr))
- {
- if (59 == chr)
- {
- parserState2 = parserState;
- switch (parserState2)
- {
- case ParserState.KeyEqual:
- case ParserState.DoubleQuoteValue:
- case ParserState.NothingYet | ParserState.Key | ParserState.KeyEqual | ParserState.KeyEnd | ParserState.UnquotedValue | ParserState.DoubleQuoteValue | ParserState.DoubleQuoteValueQuote | ParserState.SingleQuoteValue | ParserState.SingleQuoteValueQuote | ParserState.BraceQuoteValue | ParserState.BraceQuoteValueQuote | ParserState.QuotedValueEnd | ParserState.NullTermination:
- {
- if (59 == chr && currentPosition < connectionString.Length)
- {
- currentPosition++;
- }
- return currentPosition;
- }
- case ParserState.KeyEnd:
- case ParserState.SingleQuoteValue:
- case ParserState.BraceQuoteValue:
- case ParserState.QuotedValueEnd:
- {
- throw ADP.ConnectionStringSyntax(num);
- }
- case ParserState.UnquotedValue:
- {
- keyname = DbConnectionOptions.GetKeyName(buffer);
- if (!ADP.IsEmpty(ref keyname))
- {
- if (59 == chr && currentPosition < connectionString.Length)
- {
- currentPosition++;
- }
- return currentPosition;
- }
- throw ADP.ConnectionStringSyntax(num);
- }
- case ParserState.DoubleQuoteValueQuote:
- {
- keyvalue = DbConnectionOptions.GetKeyValue(buffer, true);
- char chars = keyvalue.Chars;
- if (useOdbcRules || 39 != chars && 34 != chars)
- {
- if (59 == chr && currentPosition < connectionString.Length)
- {
- currentPosition++;
- }
- return currentPosition;
- }
- throw ADP.ConnectionStringSyntax(num);
- }
- case ParserState.SingleQuoteValueQuote:
- case ParserState.BraceQuoteValueQuote:
- case ParserState.NullTermination:
- case ParserState.Key | ParserState.KeyEnd | ParserState.DoubleQuoteValue | ParserState.SingleQuoteValue | ParserState.BraceQuoteValue | ParserState.QuotedValueEnd:
- {
- keyvalue = DbConnectionOptions.GetKeyValue(buffer, false);
- if (59 == chr && currentPosition < connectionString.Length)
- {
- currentPosition++;
- }
- return currentPosition;
- }
- }
- throw ADP.InternalError(InternalErrorCode.InvalidParserState2);
- }
- if (chr != 0)
- {
- throw ADP.ConnectionStringSyntax(num);
- }
- else
- {
- parserState = ParserState.NullTermination;
- goto Label2;
- }
- }
- else
- {
- goto Label2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement