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

◆ ValidateNumber()

static void System.Text.Json.JsonWriterHelper.ValidateNumber ( ReadOnlySpan< byte > utf8FormattedNumber)
inlinestaticpackage

Definition at line 179 of file JsonWriterHelper.cs.

180 {
181 int i = 0;
182 if (utf8FormattedNumber[i] == 45)
183 {
184 i++;
185 if (utf8FormattedNumber.Length <= i)
186 {
187 throw new ArgumentException(System.SR.RequiredDigitNotFoundEndOfData, "utf8FormattedNumber");
188 }
189 }
190 if (utf8FormattedNumber[i] == 48)
191 {
192 i++;
193 }
194 else
195 {
196 for (; i < utf8FormattedNumber.Length && JsonHelpers.IsDigit(utf8FormattedNumber[i]); i++)
197 {
198 }
199 }
200 if (i == utf8FormattedNumber.Length)
201 {
202 return;
203 }
204 byte b = utf8FormattedNumber[i];
205 if (b == 46)
206 {
207 i++;
208 if (utf8FormattedNumber.Length <= i)
209 {
210 throw new ArgumentException(System.SR.RequiredDigitNotFoundEndOfData, "utf8FormattedNumber");
211 }
212 for (; i < utf8FormattedNumber.Length && JsonHelpers.IsDigit(utf8FormattedNumber[i]); i++)
213 {
214 }
215 if (i == utf8FormattedNumber.Length)
216 {
217 return;
218 }
220 }
221 if (b == 101 || b == 69)
222 {
223 i++;
224 if (utf8FormattedNumber.Length <= i)
225 {
226 throw new ArgumentException(System.SR.RequiredDigitNotFoundEndOfData, "utf8FormattedNumber");
227 }
229 if (b == 43 || b == 45)
230 {
231 i++;
232 }
233 if (utf8FormattedNumber.Length <= i)
234 {
235 throw new ArgumentException(System.SR.RequiredDigitNotFoundEndOfData, "utf8FormattedNumber");
236 }
237 for (; i < utf8FormattedNumber.Length && JsonHelpers.IsDigit(utf8FormattedNumber[i]); i++)
238 {
239 }
240 if (i == utf8FormattedNumber.Length)
241 {
242 return;
243 }
244 throw new ArgumentException(System.SR.Format(System.SR.ExpectedEndOfDigitNotFound, ThrowHelper.GetPrintableString(utf8FormattedNumber[i])), "utf8FormattedNumber");
245 }
246 throw new ArgumentException(System.SR.Format(System.SR.ExpectedEndOfDigitNotFound, ThrowHelper.GetPrintableString(b)), "utf8FormattedNumber");
247 }
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string RequiredDigitNotFoundEndOfData
Definition SR.cs:122
static string ExpectedEndOfDigitNotFound
Definition SR.cs:50
Definition SR.cs:7

References System.Text.Json.Dictionary, System.SR.ExpectedEndOfDigitNotFound, System.SR.Format(), System.Text.Json.ThrowHelper.GetPrintableString(), System.Text.Json.JsonHelpers.IsDigit(), and System.SR.RequiredDigitNotFoundEndOfData.

Referenced by System.Text.Json.Utf8JsonWriter.WriteNumberValue().