Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetKeyValuePair()

static int System.Data.Common.DbConnectionOptions.GetKeyValuePair ( string connectionString,
int currentPosition,
StringBuilder buffer,
bool useOdbcRules,
out string keyname,
out string keyvalue )
inlinestaticpackage

Definition at line 159 of file DbConnectionOptions.cs.

160 {
162 buffer.Length = 0;
163 keyname = null;
164 keyvalue = null;
165 char c = '\0';
168 {
170 switch (parserState)
171 {
172 case ParserState.NothingYet:
173 if (';' == c || char.IsWhiteSpace(c))
174 {
175 continue;
176 }
177 if (c == '\0')
178 {
179 parserState = ParserState.NullTermination;
180 continue;
181 }
182 if (char.IsControl(c))
183 {
184 throw ADP.ConnectionStringSyntax(index);
185 }
187 if ('=' != c)
188 {
190 goto IL_0248;
191 }
192 parserState = ParserState.KeyEqual;
193 continue;
194 case ParserState.Key:
195 if ('=' == c)
196 {
197 parserState = ParserState.KeyEqual;
198 continue;
199 }
200 if (!char.IsWhiteSpace(c) && char.IsControl(c))
201 {
202 throw ADP.ConnectionStringSyntax(index);
203 }
204 goto IL_0248;
205 case ParserState.KeyEqual:
206 if (!useOdbcRules && '=' == c)
207 {
209 goto IL_0248;
210 }
212 if (string.IsNullOrEmpty(keyname))
213 {
214 throw ADP.ConnectionStringSyntax(index);
215 }
216 buffer.Length = 0;
217 parserState = ParserState.KeyEnd;
218 goto case ParserState.KeyEnd;
219 case ParserState.KeyEnd:
220 if (char.IsWhiteSpace(c))
221 {
222 continue;
223 }
224 if (useOdbcRules)
225 {
226 if ('{' == c)
227 {
228 parserState = ParserState.BraceQuoteValue;
229 goto IL_0248;
230 }
231 }
232 else
233 {
234 if ('\'' == c)
235 {
236 parserState = ParserState.SingleQuoteValue;
237 continue;
238 }
239 if ('"' == c)
240 {
241 parserState = ParserState.DoubleQuoteValue;
242 continue;
243 }
244 }
245 if (';' == c || c == '\0')
246 {
247 break;
248 }
249 if (char.IsControl(c))
250 {
251 throw ADP.ConnectionStringSyntax(index);
252 }
253 parserState = ParserState.UnquotedValue;
254 goto IL_0248;
255 case ParserState.UnquotedValue:
256 if (!char.IsWhiteSpace(c) && (char.IsControl(c) || ';' == c))
257 {
258 break;
259 }
260 goto IL_0248;
261 case ParserState.DoubleQuoteValue:
262 if ('"' == c)
263 {
264 parserState = ParserState.DoubleQuoteValueQuote;
265 continue;
266 }
267 if (c == '\0')
268 {
269 throw ADP.ConnectionStringSyntax(index);
270 }
271 goto IL_0248;
272 case ParserState.DoubleQuoteValueQuote:
273 if ('"' == c)
274 {
275 parserState = ParserState.DoubleQuoteValue;
276 goto IL_0248;
277 }
279 parserState = ParserState.QuotedValueEnd;
280 goto case ParserState.QuotedValueEnd;
281 case ParserState.SingleQuoteValue:
282 if ('\'' == c)
283 {
284 parserState = ParserState.SingleQuoteValueQuote;
285 continue;
286 }
287 if (c == '\0')
288 {
289 throw ADP.ConnectionStringSyntax(index);
290 }
291 goto IL_0248;
292 case ParserState.SingleQuoteValueQuote:
293 if ('\'' == c)
294 {
295 parserState = ParserState.SingleQuoteValue;
296 goto IL_0248;
297 }
299 parserState = ParserState.QuotedValueEnd;
300 goto case ParserState.QuotedValueEnd;
301 case ParserState.BraceQuoteValue:
302 if ('}' == c)
303 {
304 parserState = ParserState.BraceQuoteValueQuote;
305 }
306 else if (c == '\0')
307 {
308 throw ADP.ConnectionStringSyntax(index);
309 }
310 goto IL_0248;
311 case ParserState.BraceQuoteValueQuote:
312 if ('}' == c)
313 {
314 parserState = ParserState.BraceQuoteValue;
315 goto IL_0248;
316 }
318 parserState = ParserState.QuotedValueEnd;
319 goto case ParserState.QuotedValueEnd;
320 case ParserState.QuotedValueEnd:
321 if (char.IsWhiteSpace(c))
322 {
323 continue;
324 }
325 if (';' != c)
326 {
327 if (c == '\0')
328 {
329 parserState = ParserState.NullTermination;
330 continue;
331 }
332 throw ADP.ConnectionStringSyntax(index);
333 }
334 break;
335 case ParserState.NullTermination:
336 if (c == '\0' || char.IsWhiteSpace(c))
337 {
338 continue;
339 }
340 throw ADP.ConnectionStringSyntax(currentPosition);
341 default:
342 {
343 throw ADP.InternalError(ADP.InternalErrorCode.InvalidParserState1);
344 }
345 IL_0248:
346 buffer.Append(c);
347 continue;
348 }
349 break;
350 }
351 switch (parserState)
352 {
353 case ParserState.Key:
354 case ParserState.DoubleQuoteValue:
355 case ParserState.SingleQuoteValue:
356 case ParserState.BraceQuoteValue:
357 throw ADP.ConnectionStringSyntax(index);
358 case ParserState.KeyEqual:
360 if (string.IsNullOrEmpty(keyname))
361 {
362 throw ADP.ConnectionStringSyntax(index);
363 }
364 break;
365 case ParserState.UnquotedValue:
366 {
368 char c2 = keyvalue[keyvalue.Length - 1];
369 if (!useOdbcRules && ('\'' == c2 || '"' == c2))
370 {
371 throw ADP.ConnectionStringSyntax(index);
372 }
373 break;
374 }
375 case ParserState.DoubleQuoteValueQuote:
376 case ParserState.SingleQuoteValueQuote:
377 case ParserState.BraceQuoteValueQuote:
378 case ParserState.QuotedValueEnd:
380 break;
381 default:
382 throw ADP.InternalError(ADP.InternalErrorCode.InvalidParserState2);
383 case ParserState.NothingYet:
384 case ParserState.KeyEnd:
385 case ParserState.NullTermination:
386 break;
387 }
388 if (';' == c && currentPosition < connectionString.Length)
389 {
391 }
392 return currentPosition;
393 }
static string GetKeyValue(StringBuilder buffer, bool trimWhitespace)
static string GetKeyName(StringBuilder buffer)

References System.buffer, System.Data.Common.ADP.ConnectionStringSyntax(), System.Data.Common.DbConnectionOptions.GetKeyName(), System.Data.Common.DbConnectionOptions.GetKeyValue(), System.index, System.Data.Common.ADP.InternalError(), and System.length.

Referenced by System.Data.Common.DbConnectionOptions.ParseInternal().