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

◆ TryGetReferenceFromJsonElement()

static bool System.Text.Json.JsonSerializer.TryGetReferenceFromJsonElement ( ref ReadStack state,
JsonElement element,
out object referenceValue )
inlinestaticpackage

Definition at line 646 of file JsonSerializer.cs.

647 {
648 bool flag = false;
649 referenceValue = null;
650 if (element.ValueKind == JsonValueKind.Object)
651 {
652 int num = 0;
653 foreach (JsonProperty item in element.EnumerateObject())
654 {
655 num++;
656 if (flag)
657 {
658 ThrowHelper.ThrowJsonException_MetadataReferenceObjectCannotContainOtherProperties();
659 }
660 else if (item.EscapedNameEquals(s_refPropertyName))
661 {
662 if (num > 1)
663 {
664 ThrowHelper.ThrowJsonException_MetadataReferenceObjectCannotContainOtherProperties();
665 }
666 if (item.Value.ValueKind != JsonValueKind.String)
667 {
668 ThrowHelper.ThrowJsonException_MetadataValueWasNotString(item.Value.ValueKind);
669 }
670 referenceValue = state.ReferenceResolver.ResolveReference(item.Value.GetString());
671 flag = true;
672 }
673 }
674 }
675 return flag;
676 }
static readonly byte[] s_refPropertyName

References System.Text.Json.JsonElement.EnumerateObject(), System.item, System.Text.Json.JsonSerializer.s_refPropertyName, System.state, System.Text.Json.ThrowHelper.ThrowJsonException_MetadataReferenceObjectCannotContainOtherProperties(), System.Text.Json.ThrowHelper.ThrowJsonException_MetadataValueWasNotString(), and System.Text.Json.JsonElement.ValueKind.

Referenced by System.Text.Json.Serialization.JsonConverter< T >.TryRead().