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

◆ ParseHelper()

static bool System.Buffers.StandardFormat.ParseHelper ( ReadOnlySpan< char > format,
out StandardFormat standardFormat,
bool throws = false )
inlinestaticprivate

Definition at line 72 of file StandardFormat.cs.

73 {
74 standardFormat = default(StandardFormat);
75 if (format.Length == 0)
76 {
77 return true;
78 }
79 char symbol = format[0];
80 byte precision;
81 if (format.Length == 1)
82 {
83 precision = byte.MaxValue;
84 }
85 else
86 {
87 uint num = 0u;
88 for (int i = 1; i < format.Length; i++)
89 {
90 uint num2 = (uint)(format[i] - 48);
91 if (num2 > 9)
92 {
93 if (!throws)
94 {
95 return false;
96 }
97 throw new FormatException(SR.Format(SR.Argument_CannotParsePrecision, (byte)99));
98 }
99 num = num * 10 + num2;
100 if (num > 99)
101 {
102 if (!throws)
103 {
104 return false;
105 }
106 throw new FormatException(SR.Format(SR.Argument_PrecisionTooLarge, (byte)99));
107 }
108 }
109 precision = (byte)num;
110 }
111 standardFormat = new StandardFormat(symbol, precision);
112 return true;
113 }
StandardFormat(char symbol, byte precision=byte.MaxValue)

References System.Buffers.StandardFormat.StandardFormat(), System.SR.Argument_CannotParsePrecision, System.SR.Argument_PrecisionTooLarge, System.SR.Format(), and System.format.

Referenced by System.Buffers.StandardFormat.Parse(), and System.Buffers.StandardFormat.TryParse().