Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlConverter.cs
Go to the documentation of this file.
3using System.Text;
4
5namespace System.Xml;
6
7internal static class XmlConverter
8{
9 public const int MaxDateTimeChars = 64;
10
11 public const int MaxInt32Chars = 16;
12
13 public const int MaxInt64Chars = 32;
14
15 public const int MaxBoolChars = 5;
16
17 public const int MaxFloatChars = 16;
18
19 public const int MaxDoubleChars = 32;
20
21 public const int MaxDecimalChars = 40;
22
23 public const int MaxUInt64Chars = 32;
24
25 public const int MaxPrimitiveChars = 64;
26
28
30
32
34 {
35 get
36 {
37 if (s_base64Encoding == null)
38 {
40 }
41 return s_base64Encoding;
42 }
43 }
44
46 {
47 get
48 {
49 if (s_utf8Encoding == null)
50 {
52 }
53 return s_utf8Encoding;
54 }
55 }
56
58 {
59 get
60 {
61 if (s_unicodeEncoding == null)
62 {
63 s_unicodeEncoding = new UnicodeEncoding(bigEndian: false, byteOrderMark: false, throwOnInvalidBytes: true);
64 }
65 return s_unicodeEncoding;
66 }
67 }
68
84
85 public static bool ToBoolean(byte[] buffer, int offset, int count)
86 {
87 if (count == 1)
88 {
89 switch (buffer[offset])
90 {
91 case 49:
92 return true;
93 case 48:
94 return false;
95 }
96 }
98 }
99
119
120 public static int ToInt32(byte[] buffer, int offset, int count)
121 {
122 if (TryParseInt32(buffer, offset, count, out var result))
123 {
124 return result;
125 }
127 }
128
148
149 public static long ToInt64(byte[] buffer, int offset, int count)
150 {
151 if (TryParseInt64(buffer, offset, count, out var result))
152 {
153 return result;
154 }
156 }
157
177
178 public static float ToSingle(byte[] buffer, int offset, int count)
179 {
180 if (TryParseSingle(buffer, offset, count, out var result))
181 {
182 return result;
183 }
185 }
186
206
207 public static double ToDouble(byte[] buffer, int offset, int count)
208 {
209 if (TryParseDouble(buffer, offset, count, out var result))
210 {
211 return result;
212 }
214 }
215
235
236 public static decimal ToDecimal(byte[] buffer, int offset, int count)
237 {
239 }
240
241 public static DateTime ToDateTime(long value)
242 {
243 try
244 {
245 return DateTime.FromBinary(value);
246 }
248 {
250 }
251 }
252
268
269 public static DateTime ToDateTime(byte[] buffer, int offset, int count)
270 {
271 if (TryParseDateTime(buffer, offset, count, out var result))
272 {
273 return result;
274 }
276 }
277
293
294 public static UniqueId ToUniqueId(byte[] buffer, int offset, int count)
295 {
297 }
298
318
319 public static TimeSpan ToTimeSpan(byte[] buffer, int offset, int count)
320 {
322 }
323
343
344 public static Guid ToGuid(byte[] buffer, int offset, int count)
345 {
346 return ToGuid(ToString(buffer, offset, count));
347 }
348
368
369 public static ulong ToUInt64(byte[] buffer, int offset, int count)
370 {
372 }
373
374 public static string ToString(byte[] buffer, int offset, int count)
375 {
376 try
377 {
379 }
381 {
383 }
384 }
385
397
398 public static byte[] ToBytes(string value)
399 {
400 try
401 {
403 }
405 {
407 }
408 }
409
410 public static int ToChars(byte[] buffer, int offset, int count, char[] chars, int charOffset)
411 {
412 try
413 {
415 }
417 {
419 }
420 }
421
422 public static string ToString(bool value)
423 {
424 if (!value)
425 {
426 return "false";
427 }
428 return "true";
429 }
430
431 public static string ToString(int value)
432 {
433 return XmlConvert.ToString(value);
434 }
435
436 public static string ToString(long value)
437 {
438 return XmlConvert.ToString(value);
439 }
440
441 public static string ToString(float value)
442 {
443 return XmlConvert.ToString(value);
444 }
445
446 public static string ToString(double value)
447 {
448 return XmlConvert.ToString(value);
449 }
450
451 public static string ToString(decimal value)
452 {
453 return XmlConvert.ToString(value);
454 }
455
456 public static string ToString(TimeSpan value)
457 {
458 return XmlConvert.ToString(value);
459 }
460
461 public static string ToString(UniqueId value)
462 {
463 return value.ToString();
464 }
465
466 public static string ToString(Guid value)
467 {
468 return value.ToString();
469 }
470
471 public static string ToString(ulong value)
472 {
473 return value.ToString(NumberFormatInfo.InvariantInfo);
474 }
475
476 public static string ToString(DateTime value)
477 {
478 byte[] array = new byte[64];
479 int num = ToChars(value, array, 0);
480 return ToString(array, 0, num);
481 }
482
483 private static string ToString(object value)
484 {
485 if (value is int)
486 {
487 return ToString((int)value);
488 }
489 if (value is long)
490 {
491 return ToString((long)value);
492 }
493 if (value is float)
494 {
495 return ToString((float)value);
496 }
497 if (value is double)
498 {
499 return ToString((double)value);
500 }
501 if (value is decimal)
502 {
503 return ToString((decimal)value);
504 }
505 if (value is TimeSpan)
506 {
507 return ToString((TimeSpan)value);
508 }
509 if (value is UniqueId)
510 {
511 return ToString((UniqueId)value);
512 }
513 if (value is Guid)
514 {
515 return ToString((Guid)value);
516 }
517 if (value is ulong)
518 {
519 return ToString((ulong)value);
520 }
521 if (value is DateTime)
522 {
523 return ToString((DateTime)value);
524 }
525 if (value is bool)
526 {
527 return ToString((bool)value);
528 }
529 return value.ToString();
530 }
531
532 public static string ToString(object[] objects)
533 {
534 if (objects.Length == 0)
535 {
536 return string.Empty;
537 }
538 string text = ToString(objects[0]);
539 if (objects.Length > 1)
540 {
542 for (int i = 1; i < objects.Length; i++)
543 {
544 stringBuilder.Append(' ');
545 stringBuilder.Append(ToString(objects[i]));
546 }
547 text = stringBuilder.ToString();
548 }
549 return text;
550 }
551
552 public static void ToQualifiedName(string qname, out string prefix, out string localName)
553 {
554 int num = qname.IndexOf(':');
555 if (num < 0)
556 {
557 prefix = string.Empty;
558 localName = Trim(qname);
559 return;
560 }
561 if (num == qname.Length - 1)
562 {
564 }
565 prefix = Trim(qname.Substring(0, num));
566 localName = Trim(qname.Substring(num + 1));
567 }
568
569 private static bool TryParseInt32(byte[] chars, int offset, int count, out int result)
570 {
571 result = 0;
572 if (count == 0)
573 {
574 return false;
575 }
576 int num = 0;
577 int num2 = offset + count;
578 if (chars[offset] == 45)
579 {
580 if (count == 1)
581 {
582 return false;
583 }
584 for (int i = offset + 1; i < num2; i++)
585 {
586 int num3 = chars[i] - 48;
587 if ((uint)num3 > 9u)
588 {
589 return false;
590 }
591 if (num < -214748364)
592 {
593 return false;
594 }
595 num *= 10;
596 if (num < int.MinValue + num3)
597 {
598 return false;
599 }
600 num -= num3;
601 }
602 }
603 else
604 {
605 for (int j = offset; j < num2; j++)
606 {
607 int num4 = chars[j] - 48;
608 if ((uint)num4 > 9u)
609 {
610 return false;
611 }
612 if (num > 214748364)
613 {
614 return false;
615 }
616 num *= 10;
617 if (num > int.MaxValue - num4)
618 {
619 return false;
620 }
621 num += num4;
622 }
623 }
624 result = num;
625 return true;
626 }
627
628 private static bool TryParseInt64(byte[] chars, int offset, int count, out long result)
629 {
630 result = 0L;
631 if (count < 11)
632 {
634 {
635 return false;
636 }
637 result = result2;
638 return true;
639 }
640 long num = 0L;
641 int num2 = offset + count;
642 if (chars[offset] == 45)
643 {
644 for (int i = offset + 1; i < num2; i++)
645 {
646 int num3 = chars[i] - 48;
647 if ((uint)num3 > 9u)
648 {
649 return false;
650 }
651 if (num < -922337203685477580L)
652 {
653 return false;
654 }
655 num *= 10;
656 if (num < long.MinValue + num3)
657 {
658 return false;
659 }
660 num -= num3;
661 }
662 }
663 else
664 {
665 for (int j = offset; j < num2; j++)
666 {
667 int num4 = chars[j] - 48;
668 if ((uint)num4 > 9u)
669 {
670 return false;
671 }
672 if (num > 922337203685477580L)
673 {
674 return false;
675 }
676 num *= 10;
677 if (num > long.MaxValue - num4)
678 {
679 return false;
680 }
681 num += num4;
682 }
683 }
684 result = num;
685 return true;
686 }
687
688 private static bool TryParseSingle(byte[] chars, int offset, int count, out float result)
689 {
690 result = 0f;
691 int num = offset + count;
692 bool flag = false;
693 if (offset < num && chars[offset] == 45)
694 {
695 flag = true;
696 offset++;
697 count--;
698 }
700 {
701 return false;
702 }
703 int num2 = 0;
704 while (offset < num)
705 {
706 int num3 = chars[offset] - 48;
707 switch (num3)
708 {
709 case -2:
710 {
711 offset++;
712 int num4 = 1;
713 while (offset < num)
714 {
715 num3 = chars[offset] - 48;
716 if ((uint)num3 >= 10u)
717 {
718 return false;
719 }
720 num4 *= 10;
721 num2 = num2 * 10 + num3;
722 offset++;
723 }
724 if (count > 8)
725 {
726 result = (float)((double)num2 / (double)num4);
727 }
728 else
729 {
730 result = (float)num2 / (float)num4;
731 }
732 if (flag)
733 {
734 result = 0f - result;
735 }
736 return true;
737 }
738 default:
739 return false;
740 case 0:
741 case 1:
742 case 2:
743 case 3:
744 case 4:
745 case 5:
746 case 6:
747 case 7:
748 case 8:
749 case 9:
750 break;
751 }
752 num2 = num2 * 10 + num3;
753 offset++;
754 }
755 if (count == 10)
756 {
757 return false;
758 }
759 if (flag)
760 {
761 result = -num2;
762 }
763 else
764 {
765 result = num2;
766 }
767 return true;
768 }
769
770 private static bool TryParseDouble(byte[] chars, int offset, int count, out double result)
771 {
772 result = 0.0;
773 int num = offset + count;
774 bool flag = false;
775 if (offset < num && chars[offset] == 45)
776 {
777 flag = true;
778 offset++;
779 count--;
780 }
782 {
783 return false;
784 }
785 int num2 = 0;
786 while (offset < num)
787 {
788 int num3 = chars[offset] - 48;
789 switch (num3)
790 {
791 case -2:
792 {
793 offset++;
794 int num4 = 1;
795 while (offset < num)
796 {
797 num3 = chars[offset] - 48;
798 if ((uint)num3 >= 10u)
799 {
800 return false;
801 }
802 num4 *= 10;
803 num2 = num2 * 10 + num3;
804 offset++;
805 }
806 if (flag)
807 {
808 result = (0.0 - (double)num2) / (double)num4;
809 }
810 else
811 {
812 result = (double)num2 / (double)num4;
813 }
814 return true;
815 }
816 default:
817 return false;
818 case 0:
819 case 1:
820 case 2:
821 case 3:
822 case 4:
823 case 5:
824 case 6:
825 case 7:
826 case 8:
827 case 9:
828 break;
829 }
830 num2 = num2 * 10 + num3;
831 offset++;
832 }
833 if (count == 10)
834 {
835 return false;
836 }
837 if (flag)
838 {
839 result = -num2;
840 }
841 else
842 {
843 result = num2;
844 }
845 return true;
846 }
847
848 public static int ToChars(int value, byte[] chars, int offset)
849 {
850 int num = ToCharsR(value, chars, offset + 16);
851 Buffer.BlockCopy(chars, offset + 16 - num, chars, offset, num);
852 return num;
853 }
854
855 public static int ToChars(long value, byte[] chars, int offset)
856 {
857 int num = ToCharsR(value, chars, offset + 32);
858 Buffer.BlockCopy(chars, offset + 32 - num, chars, offset, num);
859 return num;
860 }
861
862 public static int ToCharsR(long value, byte[] chars, int offset)
863 {
864 int num = 0;
865 if (value >= 0)
866 {
867 while (value > int.MaxValue)
868 {
869 long num2 = value / 10;
870 num++;
871 chars[--offset] = (byte)(48 + (int)(value - num2 * 10));
872 value = num2;
873 }
874 }
875 else
876 {
877 while (value < int.MinValue)
878 {
879 long num3 = value / 10;
880 num++;
881 chars[--offset] = (byte)(48 - (int)(value - num3 * 10));
882 value = num3;
883 }
884 }
885 return num + ToCharsR((int)value, chars, offset);
886 }
887
888 private unsafe static bool IsNegativeZero(float value)
889 {
890 float num = -0f;
891 return *(int*)(&value) == *(int*)(&num);
892 }
893
894 private unsafe static bool IsNegativeZero(double value)
895 {
896 double num = -0.0;
897 return *(long*)(&value) == *(long*)(&num);
898 }
899
900 private static int ToInfinity(bool isNegative, byte[] buffer, int offset)
901 {
902 if (isNegative)
903 {
904 buffer[offset] = 45;
905 buffer[offset + 1] = 73;
906 buffer[offset + 2] = 78;
907 buffer[offset + 3] = 70;
908 return 4;
909 }
910 buffer[offset] = 73;
911 buffer[offset + 1] = 78;
912 buffer[offset + 2] = 70;
913 return 3;
914 }
915
916 private static int ToZero(bool isNegative, byte[] buffer, int offset)
917 {
918 if (isNegative)
919 {
920 buffer[offset] = 45;
921 buffer[offset + 1] = 48;
922 return 2;
923 }
924 buffer[offset] = 48;
925 return 1;
926 }
927
928 public static int ToChars(double value, byte[] buffer, int offset)
929 {
930 if (double.IsInfinity(value))
931 {
932 return ToInfinity(double.IsNegativeInfinity(value), buffer, offset);
933 }
934 if (value == 0.0)
935 {
937 }
939 }
940
941 public static int ToChars(float value, byte[] buffer, int offset)
942 {
943 if (float.IsInfinity(value))
944 {
945 return ToInfinity(float.IsNegativeInfinity(value), buffer, offset);
946 }
947 if ((double)value == 0.0)
948 {
950 }
952 }
953
954 public static int ToChars(decimal value, byte[] buffer, int offset)
955 {
957 }
958
959 public static int ToChars(ulong value, byte[] buffer, int offset)
960 {
962 }
963
964 private static int ToAsciiChars(string s, byte[] buffer, int offset)
965 {
966 for (int i = 0; i < s.Length; i++)
967 {
968 buffer[offset++] = (byte)s[i];
969 }
970 return s.Length;
971 }
972
973 public static int ToChars(bool value, byte[] buffer, int offset)
974 {
975 if (value)
976 {
977 buffer[offset] = 116;
978 buffer[offset + 1] = 114;
979 buffer[offset + 2] = 117;
980 buffer[offset + 3] = 101;
981 return 4;
982 }
983 buffer[offset] = 102;
984 buffer[offset + 1] = 97;
985 buffer[offset + 2] = 108;
986 buffer[offset + 3] = 115;
987 buffer[offset + 4] = 101;
988 return 5;
989 }
990
991 private static int ToInt32D2(byte[] chars, int offset)
992 {
993 byte b = (byte)(chars[offset] - 48);
994 byte b2 = (byte)(chars[offset + 1] - 48);
995 if (b > 9 || b2 > 9)
996 {
997 return -1;
998 }
999 return 10 * b + b2;
1000 }
1001
1002 private static int ToInt32D4(byte[] chars, int offset, int count)
1003 {
1004 return ToInt32D7(chars, offset, count);
1005 }
1006
1007 private static int ToInt32D7(byte[] chars, int offset, int count)
1008 {
1009 int num = 0;
1010 for (int i = 0; i < count; i++)
1011 {
1012 byte b = (byte)(chars[offset + i] - 48);
1013 if (b > 9)
1014 {
1015 return -1;
1016 }
1017 num = num * 10 + b;
1018 }
1019 return num;
1020 }
1021
1022 private static bool TryParseDateTime(byte[] chars, int offset, int count, out DateTime result)
1023 {
1024 int num = offset + count;
1025 result = DateTime.MaxValue;
1026 if (count < 19)
1027 {
1028 return false;
1029 }
1030 if (chars[offset + 4] != 45 || chars[offset + 7] != 45 || chars[offset + 10] != 84 || chars[offset + 13] != 58 || chars[offset + 16] != 58)
1031 {
1032 return false;
1033 }
1034 int num2 = ToInt32D4(chars, offset, 4);
1035 int num3 = ToInt32D2(chars, offset + 5);
1036 int num4 = ToInt32D2(chars, offset + 8);
1037 int num5 = ToInt32D2(chars, offset + 11);
1038 int num6 = ToInt32D2(chars, offset + 14);
1039 int num7 = ToInt32D2(chars, offset + 17);
1040 if ((num2 | num3 | num4 | num5 | num6 | num7) < 0)
1041 {
1042 return false;
1043 }
1044 DateTimeKind kind = DateTimeKind.Unspecified;
1045 offset += 19;
1046 int num8 = 0;
1047 if (offset < num && chars[offset] == 46)
1048 {
1049 offset++;
1050 int num9 = offset;
1051 while (offset < num)
1052 {
1053 byte b = chars[offset];
1054 if (b < 48 || b > 57)
1055 {
1056 break;
1057 }
1058 offset++;
1059 }
1060 int num10 = offset - num9;
1062 {
1063 return false;
1064 }
1066 if (num8 < 0)
1067 {
1068 return false;
1069 }
1070 for (int i = num10; i < 7; i++)
1071 {
1072 num8 *= 10;
1073 }
1074 }
1075 bool flag = false;
1076 int num11 = 0;
1077 int num12 = 0;
1078 if (offset < num)
1079 {
1080 byte b2 = chars[offset];
1081 switch (b2)
1082 {
1083 case 90:
1084 offset++;
1085 kind = DateTimeKind.Utc;
1086 break;
1087 case 43:
1088 case 45:
1089 offset++;
1090 if (offset + 5 > num || chars[offset + 2] != 58)
1091 {
1092 return false;
1093 }
1094 kind = DateTimeKind.Utc;
1095 flag = true;
1097 num12 = ToInt32D2(chars, offset + 3);
1098 if ((num11 | num12) < 0)
1099 {
1100 return false;
1101 }
1102 if (b2 == 43)
1103 {
1104 num11 = -num11;
1105 num12 = -num12;
1106 }
1107 offset += 5;
1108 break;
1109 }
1110 }
1111 if (offset < num)
1112 {
1113 return false;
1114 }
1116 try
1117 {
1118 dateTime = new DateTime(num2, num3, num4, num5, num6, num7, kind);
1119 }
1120 catch (ArgumentException)
1121 {
1122 return false;
1123 }
1124 if (num8 > 0)
1125 {
1126 dateTime = dateTime.AddTicks(num8);
1127 }
1128 if (flag)
1129 {
1130 try
1131 {
1133 dateTime = (((num11 < 0 || !(dateTime < DateTime.MaxValue - timeSpan)) && (num11 >= 0 || !(dateTime > DateTime.MinValue - timeSpan))) ? dateTime.ToLocalTime().Add(timeSpan) : dateTime.Add(timeSpan).ToLocalTime());
1134 }
1136 {
1137 return false;
1138 }
1139 }
1140 result = dateTime;
1141 return true;
1142 }
1143
1144 public static int ToCharsR(int value, byte[] chars, int offset)
1145 {
1146 int num = 0;
1147 if (value >= 0)
1148 {
1149 while (value >= 10)
1150 {
1151 int num2 = value / 10;
1152 num++;
1153 chars[--offset] = (byte)(48 + (value - num2 * 10));
1154 value = num2;
1155 }
1156 chars[--offset] = (byte)(48 + value);
1157 return num + 1;
1158 }
1159 while (value <= -10)
1160 {
1161 int num3 = value / 10;
1162 num++;
1163 chars[--offset] = (byte)(48 - (value - num3 * 10));
1164 value = num3;
1165 }
1166 chars[--offset] = (byte)(48 - value);
1167 chars[--offset] = 45;
1168 return num + 2;
1169 }
1170
1171 private static int ToCharsD2(int value, byte[] chars, int offset)
1172 {
1173 if (value < 10)
1174 {
1175 chars[offset] = 48;
1176 chars[offset + 1] = (byte)(48 + value);
1177 }
1178 else
1179 {
1180 int num = value / 10;
1181 chars[offset] = (byte)(48 + num);
1182 chars[offset + 1] = (byte)(48 + value - num * 10);
1183 }
1184 return 2;
1185 }
1186
1187 private static int ToCharsD4(int value, byte[] chars, int offset)
1188 {
1189 ToCharsD2(value / 100, chars, offset);
1190 ToCharsD2(value % 100, chars, offset + 2);
1191 return 4;
1192 }
1193
1194 private static int ToCharsD7(int value, byte[] chars, int offset)
1195 {
1196 int num = 7 - ToCharsR(value, chars, offset + 7);
1197 for (int i = 0; i < num; i++)
1198 {
1199 chars[offset + i] = 48;
1200 }
1201 int num2 = 7;
1202 while (num2 > 0 && chars[offset + num2 - 1] == 48)
1203 {
1204 num2--;
1205 }
1206 return num2;
1207 }
1208
1209 public static int ToChars(DateTime value, byte[] chars, int offset)
1210 {
1211 int num = offset;
1212 offset += ToCharsD4(value.Year, chars, offset);
1213 chars[offset++] = 45;
1214 offset += ToCharsD2(value.Month, chars, offset);
1215 chars[offset++] = 45;
1216 offset += ToCharsD2(value.Day, chars, offset);
1217 chars[offset++] = 84;
1218 offset += ToCharsD2(value.Hour, chars, offset);
1219 chars[offset++] = 58;
1220 offset += ToCharsD2(value.Minute, chars, offset);
1221 chars[offset++] = 58;
1222 offset += ToCharsD2(value.Second, chars, offset);
1223 int num2 = (int)(value.Ticks % 10000000);
1224 if (num2 != 0)
1225 {
1226 chars[offset++] = 46;
1228 }
1229 switch (value.Kind)
1230 {
1231 case DateTimeKind.Local:
1232 {
1233 TimeSpan utcOffset = TimeZoneInfo.Local.GetUtcOffset(value);
1234 if (utcOffset.Ticks < 0)
1235 {
1236 chars[offset++] = 45;
1237 }
1238 else
1239 {
1240 chars[offset++] = 43;
1241 }
1243 chars[offset++] = 58;
1244 offset += ToCharsD2(Math.Abs(utcOffset.Minutes), chars, offset);
1245 break;
1246 }
1247 case DateTimeKind.Utc:
1248 chars[offset++] = 90;
1249 break;
1250 default:
1252 case DateTimeKind.Unspecified:
1253 break;
1254 }
1255 return offset - num;
1256 }
1257
1258 public static bool IsWhitespace(string s)
1259 {
1260 for (int i = 0; i < s.Length; i++)
1261 {
1262 if (!IsWhitespace(s[i]))
1263 {
1264 return false;
1265 }
1266 }
1267 return true;
1268 }
1269
1270 public static bool IsWhitespace(char ch)
1271 {
1272 if (ch <= ' ')
1273 {
1274 if (ch != ' ' && ch != '\t' && ch != '\r')
1275 {
1276 return ch == '\n';
1277 }
1278 return true;
1279 }
1280 return false;
1281 }
1282
1283 public static string StripWhitespace(string s)
1284 {
1285 int num = s.Length;
1286 for (int i = 0; i < s.Length; i++)
1287 {
1288 if (IsWhitespace(s[i]))
1289 {
1290 num--;
1291 }
1292 }
1293 if (num == s.Length)
1294 {
1295 return s;
1296 }
1297 return string.Create(num, s, delegate(Span<char> chars, string s)
1298 {
1299 int num2 = 0;
1300 foreach (char c in s)
1301 {
1302 if (!IsWhitespace(c))
1303 {
1304 chars[num2++] = c;
1305 }
1306 }
1307 });
1308 }
1309
1310 private static string Trim(string s)
1311 {
1312 int i;
1313 for (i = 0; i < s.Length && IsWhitespace(s[i]); i++)
1314 {
1315 }
1316 int num = s.Length;
1317 while (num > 0 && IsWhitespace(s[num - 1]))
1318 {
1319 num--;
1320 }
1321 if (i == 0 && num == s.Length)
1322 {
1323 return s;
1324 }
1325 if (num == 0)
1326 {
1327 return string.Empty;
1328 }
1329 return s.Substring(i, num - i);
1330 }
1331}
static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count)
Definition Buffer.cs:102
static double Abs(double value)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string XmlInvalidQualifiedName
Definition SR.cs:438
Definition SR.cs:7
unsafe override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
unsafe override string GetString(byte[] bytes, int index, int count)
unsafe override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex)
unsafe override string GetString(byte[] bytes, int index, int count)
static TimeZoneInfo Local
static bool ToBoolean(string s)
static int ToInt32(string s)
static string ToString(bool value)
static float ToSingle(string s)
static TimeSpan ToTimeSpan(string s)
static double ToDouble(string s)
static DateTime ToDateTime(string s)
static decimal ToDecimal(string s)
static long ToInt64(string s)
static int ToCharsR(int value, byte[] chars, int offset)
static UniqueId ToUniqueId(byte[] buffer, int offset, int count)
static float ToSingle(string value)
static int ToInt32D4(byte[] chars, int offset, int count)
static UTF8Encoding s_utf8Encoding
static Guid ToGuid(byte[] buffer, int offset, int count)
static bool ToBoolean(string value)
static double ToDouble(byte[] buffer, int offset, int count)
static string ToString(ulong value)
static bool ToBoolean(byte[] buffer, int offset, int count)
static int ToCharsR(long value, byte[] chars, int offset)
static bool TryParseDouble(byte[] chars, int offset, int count, out double result)
static string ToString(decimal value)
static string ToStringUnicode(byte[] buffer, int offset, int count)
static int ToInt32D2(byte[] chars, int offset)
static bool IsWhitespace(string s)
static unsafe bool IsNegativeZero(double value)
static string ToString(double value)
static bool IsWhitespace(char ch)
static int ToAsciiChars(string s, byte[] buffer, int offset)
static string ToString(long value)
static bool TryParseInt64(byte[] chars, int offset, int count, out long result)
static decimal ToDecimal(string value)
static TimeSpan ToTimeSpan(byte[] buffer, int offset, int count)
static string ToString(float value)
static int ToCharsD4(int value, byte[] chars, int offset)
static int ToInt32D7(byte[] chars, int offset, int count)
static int ToChars(ulong value, byte[] buffer, int offset)
static int ToInt32(string value)
static int ToChars(DateTime value, byte[] chars, int offset)
static float ToSingle(byte[] buffer, int offset, int count)
static long ToInt64(string value)
static decimal ToDecimal(byte[] buffer, int offset, int count)
static int ToChars(decimal value, byte[] buffer, int offset)
static int ToChars(long value, byte[] chars, int offset)
static DateTime ToDateTime(byte[] buffer, int offset, int count)
static int ToChars(bool value, byte[] buffer, int offset)
static string ToString(bool value)
static byte[] ToBytes(string value)
static string ToString(DateTime value)
static string ToString(object value)
static string ToString(UniqueId value)
static string ToString(int value)
static bool TryParseInt32(byte[] chars, int offset, int count, out int result)
static ulong ToUInt64(byte[] buffer, int offset, int count)
static Guid ToGuid(string value)
static string ToString(byte[] buffer, int offset, int count)
static string ToString(TimeSpan value)
static string ToString(Guid value)
static int ToInfinity(bool isNegative, byte[] buffer, int offset)
static int ToInt32(byte[] buffer, int offset, int count)
static int ToChars(int value, byte[] chars, int offset)
static int ToCharsD7(int value, byte[] chars, int offset)
static bool TryParseDateTime(byte[] chars, int offset, int count, out DateTime result)
static int ToChars(float value, byte[] buffer, int offset)
static Base64Encoding Base64Encoding
static TimeSpan ToTimeSpan(string value)
static int ToChars(byte[] buffer, int offset, int count, char[] chars, int charOffset)
static UTF8Encoding UTF8Encoding
static int ToZero(bool isNegative, byte[] buffer, int offset)
static long ToInt64(byte[] buffer, int offset, int count)
static void ToQualifiedName(string qname, out string prefix, out string localName)
static Base64Encoding s_base64Encoding
static int ToChars(double value, byte[] buffer, int offset)
static unsafe bool IsNegativeZero(float value)
static ulong ToUInt64(string value)
static string ToString(object[] objects)
static DateTime ToDateTime(string value)
static UnicodeEncoding UnicodeEncoding
static UnicodeEncoding s_unicodeEncoding
static bool TryParseSingle(byte[] chars, int offset, int count, out float result)
static double ToDouble(string value)
static int ToCharsD2(int value, byte[] chars, int offset)
static DateTime ToDateTime(long value)
static string StripWhitespace(string s)
static string Trim(string s)
static UniqueId ToUniqueId(string value)
static XmlException CreateEncodingException(byte[] buffer, int offset, int count, Exception exception)
static XmlException CreateConversionException(string type, Exception exception)
static readonly DateTime MaxValue
Definition DateTime.cs:37
static DateTime FromBinary(long dateData)
Definition DateTime.cs:671