Skip to content

JsonWorkspace.TakeOwnership Method

Definition

Namespace: Corvus.Text.Json
Assembly: Corvus.Text.Json.dll
Source: JsonWorkspace.cs

TakeOwnership(IJsonDocument)

Transfers ownership of a document to this workspace. The document will be disposed when the workspace is disposed or reset.

public void TakeOwnership(IJsonDocument document)

Parameters

Name Type Description
document IJsonDocument The document to take ownership of.

Remarks

Use this for caller-owned documents (e.g., ParsedJsonDocument) whose lifetime should be tied to the workspace. This is particularly useful in server handler scenarios where parsed response data must outlive the handler method but should be cleaned up when the workspace is disposed. This method is idempotent — calling it multiple times with the same document has no additional effect.

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