Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ TryFormat() [8/16]

static bool System.Buffers.Text.Utf8Formatter.TryFormat ( Guid value,
Span< byte > destination,
out int bytesWritten,
StandardFormat format = default(StandardFormat) )
inlinestatic

Definition at line 685 of file Utf8Formatter.cs.

686 {
687 int num;
688 switch (FormattingHelpers.GetSymbolOrDefault(in format, 'D'))
689 {
690 case 'D':
691 num = -2147483612;
692 break;
693 case 'B':
694 num = -2139260122;
695 break;
696 case 'P':
697 num = -2144786394;
698 break;
699 case 'N':
700 num = 32;
701 break;
702 default:
703 return FormattingHelpers.TryFormatThrowFormatException(out bytesWritten);
704 }
705 if ((byte)num > destination.Length)
706 {
707 bytesWritten = 0;
708 return false;
709 }
710 bytesWritten = (byte)num;
711 num >>= 8;
712 if ((byte)num != 0)
713 {
714 destination[0] = (byte)num;
715 destination = destination.Slice(1);
716 }
717 num >>= 8;
718 DecomposedGuid decomposedGuid = default(DecomposedGuid);
719 decomposedGuid.Guid = value;
720 _ = ref destination[8];
721 _ = BitConverter.IsLittleEndian;
722 HexConverter.ToBytesBuffer(decomposedGuid.Byte03, destination, 0, HexConverter.Casing.Lower);
723 HexConverter.ToBytesBuffer(decomposedGuid.Byte02, destination, 2, HexConverter.Casing.Lower);
724 HexConverter.ToBytesBuffer(decomposedGuid.Byte01, destination, 4, HexConverter.Casing.Lower);
725 HexConverter.ToBytesBuffer(decomposedGuid.Byte00, destination, 6, HexConverter.Casing.Lower);
726 if (num < 0)
727 {
728 destination[8] = 45;
729 destination = destination.Slice(9);
730 }
731 else
732 {
733 destination = destination.Slice(8);
734 }
735 _ = ref destination[4];
736 _ = BitConverter.IsLittleEndian;
737 HexConverter.ToBytesBuffer(decomposedGuid.Byte05, destination, 0, HexConverter.Casing.Lower);
738 HexConverter.ToBytesBuffer(decomposedGuid.Byte04, destination, 2, HexConverter.Casing.Lower);
739 if (num < 0)
740 {
741 destination[4] = 45;
742 destination = destination.Slice(5);
743 }
744 else
745 {
746 destination = destination.Slice(4);
747 }
748 _ = ref destination[4];
749 _ = BitConverter.IsLittleEndian;
750 HexConverter.ToBytesBuffer(decomposedGuid.Byte07, destination, 0, HexConverter.Casing.Lower);
751 HexConverter.ToBytesBuffer(decomposedGuid.Byte06, destination, 2, HexConverter.Casing.Lower);
752 if (num < 0)
753 {
754 destination[4] = 45;
755 destination = destination.Slice(5);
756 }
757 else
758 {
759 destination = destination.Slice(4);
760 }
761 _ = ref destination[4];
762 HexConverter.ToBytesBuffer(decomposedGuid.Byte08, destination, 0, HexConverter.Casing.Lower);
763 HexConverter.ToBytesBuffer(decomposedGuid.Byte09, destination, 2, HexConverter.Casing.Lower);
764 if (num < 0)
765 {
766 destination[4] = 45;
767 destination = destination.Slice(5);
768 }
769 else
770 {
771 destination = destination.Slice(4);
772 }
773 _ = ref destination[11];
774 HexConverter.ToBytesBuffer(decomposedGuid.Byte10, destination, 0, HexConverter.Casing.Lower);
775 HexConverter.ToBytesBuffer(decomposedGuid.Byte11, destination, 2, HexConverter.Casing.Lower);
776 HexConverter.ToBytesBuffer(decomposedGuid.Byte12, destination, 4, HexConverter.Casing.Lower);
777 HexConverter.ToBytesBuffer(decomposedGuid.Byte13, destination, 6, HexConverter.Casing.Lower);
778 HexConverter.ToBytesBuffer(decomposedGuid.Byte14, destination, 8, HexConverter.Casing.Lower);
779 HexConverter.ToBytesBuffer(decomposedGuid.Byte15, destination, 10, HexConverter.Casing.Lower);
780 if ((byte)num != 0)
781 {
782 destination[12] = (byte)num;
783 }
784 return true;
785 }

References System.Buffers.Text.Utf8Formatter.DecomposedGuid.Byte00, System.Buffers.Text.Utf8Formatter.DecomposedGuid.Byte01, System.Buffers.Text.Utf8Formatter.DecomposedGuid.Byte02, System.Buffers.Text.Utf8Formatter.DecomposedGuid.Byte03, System.Buffers.Text.Utf8Formatter.DecomposedGuid.Byte04, System.Buffers.Text.Utf8Formatter.DecomposedGuid.Byte05, System.Buffers.Text.Utf8Formatter.DecomposedGuid.Byte06, System.Buffers.Text.Utf8Formatter.DecomposedGuid.Byte07, System.Buffers.Text.Utf8Formatter.DecomposedGuid.Byte08, System.Buffers.Text.Utf8Formatter.DecomposedGuid.Byte09, System.Buffers.Text.Utf8Formatter.DecomposedGuid.Byte10, System.Buffers.Text.Utf8Formatter.DecomposedGuid.Byte11, System.Buffers.Text.Utf8Formatter.DecomposedGuid.Byte12, System.Buffers.Text.Utf8Formatter.DecomposedGuid.Byte13, System.Buffers.Text.Utf8Formatter.DecomposedGuid.Byte14, System.Buffers.Text.Utf8Formatter.DecomposedGuid.Byte15, System.destination, System.format, System.Buffers.Text.FormattingHelpers.GetSymbolOrDefault(), System.BitConverter.IsLittleEndian, System.HexConverter.ToBytesBuffer(), System.Buffers.Text.FormattingHelpers.TryFormatThrowFormatException(), and System.value.