Skip to content

IMutableJsonDocument.RefreshElementUnsafe Method

Definition

Namespace: Corvus.Text.Json.Internal
Assembly: Corvus.Text.Json.dll
Source: IMutableJsonDocument.cs

RefreshElementUnsafe(int)

Creates a fresh element of type TElement for the element at the specified index, capturing the document's current version.

public abstract TElement RefreshElementUnsafe<TElement>(int index)
    where TElement : struct, IJsonElement<TElement>

Type Parameters

Parameter Description
TElement The element type to return.

Parameters

Name Type Description
index int The metadata index of the element.

Returns

TElement

A new element pointing at index, stamped with the document's current Version.

Remarks

This is an unsafe operation: it does not validate that index still addresses the same logical element. It exists to refresh a held element after mutations that are known to have affected only that element's descendant nodes (so its own start index — which precedes all of its content — is unchanged), bringing its cached version up to date so subsequent staleness checks pass. For example, RFC 7396 merge-patch application re-mints the parent element after recursively merging into one of its child objects.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create and review issues and pull requests.

Open an issue