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

◆ TryParse() [1/2]

static Exception System.Xml.Schema.XsdDuration.TryParse ( string s,
DurationType durationType,
out XsdDuration result )
inlinestaticpackage

Definition at line 332 of file XsdDuration.cs.

333 {
334 Parts parts = Parts.HasNone;
335 result = default(XsdDuration);
336 s = s.Trim();
337 int length = s.Length;
338 int offset = 0;
339 int i = 0;
340 int result2;
341 if (offset < length)
342 {
343 if (s[offset] == '-')
344 {
345 offset++;
346 result._nanoseconds = 2147483648u;
347 }
348 else
349 {
351 }
352 if (offset < length && s[offset++] == 'P')
353 {
355 if (text != null)
356 {
357 goto IL_02ec;
358 }
359 if (offset < length)
360 {
361 if (s[offset] != 'Y')
362 {
363 goto IL_00c1;
364 }
365 if (i != 0)
366 {
367 parts |= Parts.HasYears;
369 if (++offset == length)
370 {
371 goto IL_02b8;
372 }
374 if (text != null)
375 {
376 goto IL_02ec;
377 }
378 if (offset < length)
379 {
380 goto IL_00c1;
381 }
382 }
383 }
384 }
385 }
386 goto IL_02d5;
387 IL_02ec:
388 return new OverflowException(System.SR.Format(System.SR.XmlConvert_Overflow, s, durationType));
389 IL_014b:
390 if (s[offset] != 'T')
391 {
392 goto IL_02b0;
393 }
394 if (i == 0)
395 {
396 offset++;
398 if (text != null)
399 {
400 goto IL_02ec;
401 }
402 if (offset < length)
403 {
404 if (s[offset] != 'H')
405 {
406 goto IL_01c4;
407 }
408 if (i != 0)
409 {
410 parts |= Parts.HasHours;
412 if (++offset == length)
413 {
414 goto IL_02b8;
415 }
417 if (text != null)
418 {
419 goto IL_02ec;
420 }
421 if (offset < length)
422 {
423 goto IL_01c4;
424 }
425 }
426 }
427 }
428 goto IL_02d5;
429 IL_00c1:
430 if (s[offset] != 'M')
431 {
432 goto IL_0106;
433 }
434 if (i != 0)
435 {
436 parts |= Parts.HasMonths;
438 if (++offset == length)
439 {
440 goto IL_02b8;
441 }
443 if (text != null)
444 {
445 goto IL_02ec;
446 }
447 if (offset < length)
448 {
449 goto IL_0106;
450 }
451 }
452 goto IL_02d5;
453 IL_020a:
454 if (s[offset] == '.')
455 {
456 offset++;
457 parts |= Parts.HasSeconds;
460 if (text != null)
461 {
462 goto IL_02ec;
463 }
464 if (i == 0)
465 {
466 result2 = 0;
467 }
468 while (i > 9)
469 {
470 result2 /= 10;
471 i--;
472 }
473 for (; i < 9; i++)
474 {
475 result2 *= 10;
476 }
478 if (offset >= length || s[offset] != 'S')
479 {
480 goto IL_02d5;
481 }
482 if (++offset == length)
483 {
484 goto IL_02b8;
485 }
486 }
487 else if (s[offset] == 'S')
488 {
489 if (i == 0)
490 {
491 goto IL_02d5;
492 }
493 parts |= Parts.HasSeconds;
495 if (++offset == length)
496 {
497 goto IL_02b8;
498 }
499 }
500 goto IL_02b0;
501 IL_02d5:
502 return new FormatException(System.SR.Format(System.SR.XmlConvert_BadFormat, s, durationType));
503 IL_01c4:
504 if (s[offset] != 'M')
505 {
506 goto IL_020a;
507 }
508 if (i != 0)
509 {
510 parts |= Parts.HasMinutes;
512 if (++offset == length)
513 {
514 goto IL_02b8;
515 }
517 if (text != null)
518 {
519 goto IL_02ec;
520 }
521 if (offset < length)
522 {
523 goto IL_020a;
524 }
525 }
526 goto IL_02d5;
527 IL_02b0:
528 if (i == 0 && offset == length)
529 {
530 goto IL_02b8;
531 }
532 goto IL_02d5;
533 IL_0106:
534 if (s[offset] != 'D')
535 {
536 goto IL_014b;
537 }
538 if (i != 0)
539 {
540 parts |= Parts.HasDays;
542 if (++offset == length)
543 {
544 goto IL_02b8;
545 }
547 if (text != null)
548 {
549 goto IL_02ec;
550 }
551 if (offset < length)
552 {
553 goto IL_014b;
554 }
555 }
556 goto IL_02d5;
557 IL_02b8:
558 if (parts != 0)
559 {
560 if (durationType == DurationType.DayTimeDuration)
561 {
562 if ((parts & (Parts)3) == 0)
563 {
564 goto IL_02d3;
565 }
566 }
567 else if (durationType != DurationType.YearMonthDuration || (parts & (Parts)(-4)) == 0)
568 {
569 goto IL_02d3;
570 }
571 }
572 goto IL_02d5;
573 IL_02d3:
574 return null;
575 }
static string XmlConvert_Overflow
Definition SR.cs:372
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string XmlConvert_BadFormat
Definition SR.cs:370
Definition SR.cs:7
XsdDuration(bool isNegative, int years, int months, int days, int hours, int minutes, int seconds, int nanoseconds)
static string TryParseDigits(string s, ref int offset, bool eatDigits, out int result, out int numDigits)

References System.Xml.Dictionary, System.SR.Format(), System.length, System.offset, System.s, System.text, System.Xml.Schema.XsdDuration.TryParseDigits(), System.SR.XmlConvert_BadFormat, and System.SR.XmlConvert_Overflow.