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

◆ TryParseExactD()

static bool System.Guid.TryParseExactD ( ReadOnlySpan< char > guidString,
ref GuidResult result )
inlinestaticprivate

Definition at line 335 of file Guid.cs.

336 {
337 if (guidString.Length != 36 || guidString[8] != '-' || guidString[13] != '-' || guidString[18] != '-' || guidString[23] != '-')
338 {
339 result.SetFailure(overflow: false, (guidString.Length != 36) ? "Format_GuidInvLen" : "Format_GuidDashes");
340 return false;
341 }
342 Span<byte> span = MemoryMarshal.AsBytes(new Span<GuidResult>(ref result, 1));
343 int invalidIfNegative = 0;
344 span[0] = DecodeByte(guidString[6], guidString[7], ref invalidIfNegative);
345 span[1] = DecodeByte(guidString[4], guidString[5], ref invalidIfNegative);
346 span[2] = DecodeByte(guidString[2], guidString[3], ref invalidIfNegative);
347 span[3] = DecodeByte(guidString[0], guidString[1], ref invalidIfNegative);
348 span[4] = DecodeByte(guidString[11], guidString[12], ref invalidIfNegative);
349 span[5] = DecodeByte(guidString[9], guidString[10], ref invalidIfNegative);
350 span[6] = DecodeByte(guidString[16], guidString[17], ref invalidIfNegative);
351 span[7] = DecodeByte(guidString[14], guidString[15], ref invalidIfNegative);
352 span[8] = DecodeByte(guidString[19], guidString[20], ref invalidIfNegative);
353 span[9] = DecodeByte(guidString[21], guidString[22], ref invalidIfNegative);
354 span[10] = DecodeByte(guidString[24], guidString[25], ref invalidIfNegative);
355 span[11] = DecodeByte(guidString[26], guidString[27], ref invalidIfNegative);
356 span[12] = DecodeByte(guidString[28], guidString[29], ref invalidIfNegative);
357 span[13] = DecodeByte(guidString[30], guidString[31], ref invalidIfNegative);
358 span[14] = DecodeByte(guidString[32], guidString[33], ref invalidIfNegative);
359 span[15] = DecodeByte(guidString[34], guidString[35], ref invalidIfNegative);
360 if (invalidIfNegative >= 0)
361 {
362 if (!BitConverter.IsLittleEndian)
363 {
364 }
365 return true;
366 }
367 if (guidString.IndexOfAny('X', 'x', '+') != -1 && TryCompatParsing(guidString, ref result))
368 {
369 return true;
370 }
371 result.SetFailure(overflow: false, "Format_GuidInvalidChar");
372 return false;
373 static bool TryCompatParsing(ReadOnlySpan<char> guidString, ref GuidResult result)
374 {
375 if (TryParseHex(guidString.Slice(0, 8), out result._a) && TryParseHex(guidString.Slice(9, 4), out var result2))
376 {
377 result._b = (ushort)result2;
378 if (TryParseHex(guidString.Slice(14, 4), out result2))
379 {
380 result._c = (ushort)result2;
381 if (TryParseHex(guidString.Slice(19, 4), out result2))
382 {
383 if (!BitConverter.IsLittleEndian)
384 {
385 }
386 result._de = BinaryPrimitives.ReverseEndianness((ushort)result2);
387 if (TryParseHex(guidString.Slice(24, 4), out result2))
388 {
389 if (!BitConverter.IsLittleEndian)
390 {
391 }
392 result._fg = BinaryPrimitives.ReverseEndianness((ushort)result2);
393 if (Number.TryParseUInt32HexNumberStyle(guidString.Slice(28, 8), NumberStyles.AllowHexSpecifier, out result2) == Number.ParsingStatus.OK)
394 {
395 if (!BitConverter.IsLittleEndian)
396 {
397 }
398 result._hijk = BinaryPrimitives.ReverseEndianness(result2);
399 return true;
400 }
401 }
402 }
403 }
404 }
405 return false;
406 }
407 }
static sbyte ReverseEndianness(sbyte value)
static byte DecodeByte(nuint ch1, nuint ch2, ref int invalidIfNegative)
Definition Guid.cs:568
static bool TryParseHex(ReadOnlySpan< char > guidString, out ushort result, ref bool overflow)
Definition Guid.cs:587

References System.Guid.DecodeByte(), System.BitConverter.IsLittleEndian, System.ReadOnlySpan< T >.Length, System.Buffers.Binary.BinaryPrimitives.ReverseEndianness(), System.ReadOnlySpan< T >.Slice(), System.Guid.TryParseHex(), and System.Number.TryParseUInt32HexNumberStyle().

Referenced by System.Guid.ParseExact(), System.Guid.TryParseExact(), System.Guid.TryParseExactB(), System.Guid.TryParseExactP(), and System.Guid.TryParseGuid().