Table of Contents

Struct ContextResponse

Namespace
DirectoryToObject
Assembly
DirectoryToObject.dll

Response returned after processing a directory entry. This represents the fact that successful processing results in one of two cases: a JsonNode to be merged into the overall result or a IFileSystemDirectory instance into which the loader should recurse.

public readonly struct ContextResponse
Inherited Members

Constructors

ContextResponse(Func<JsonNode?, JsonNode?>?, ContextResponse)

A new context response that is identical to another response, but with the node transformer function replaced.

public ContextResponse(Func<JsonNode?, JsonNode?>? nodeTransformer, ContextResponse otherResponse)

Parameters

nodeTransformer Func<JsonNode, JsonNode>

The new node transformation function.

otherResponse ContextResponse

The other context response to copy.

ContextResponse(string, ContextResponse)

A new context response that is identical to another response, but with the property name replaced.

public ContextResponse(string propertyName, ContextResponse otherResponse)

Parameters

propertyName string

The new property name to use.

otherResponse ContextResponse

The other context response to copy.

ContextResponse(string, IFileSystemDirectory, IDirectoryLoaderContextHandler?, Func<JsonNode?, JsonNode?>?)

A new response containing a IFileSystemDirectory into which the directory loader should recurse, optionally with a new DirectoryToObject.Internals.DefaultDirectoryLoaderContextHandler to use.

public ContextResponse(string propertyName, IFileSystemDirectory directory, IDirectoryLoaderContextHandler? childContext, Func<JsonNode?, JsonNode?>? nodeTransformer = null)

Parameters

propertyName string

The name in the parent JsonObject into which the directory should be loaded.

directory IFileSystemDirectory

The directory to recurse into.

childContext IDirectoryLoaderContextHandler

The optional new DirectoryToObject.Internals.DefaultDirectoryLoaderContextHandler to use when loading the directory.

nodeTransformer Func<JsonNode, JsonNode>

An optional node transformation function.

ContextResponse(string, JsonNode?, Func<JsonNode?, JsonNode?>?)

A new response containing a JsonNode that will be set or merged into the PropertyName property of the parent JSON object.

public ContextResponse(string propertyName, JsonNode? node, Func<JsonNode?, JsonNode?>? nodeTransformer = null)

Parameters

propertyName string

The name in the parent JsonObject into which the node should be set or merged.

node JsonNode

The JsonNode to set or merge.

nodeTransformer Func<JsonNode, JsonNode>

An optional node transformation function.

Fields

ChildContext

An optional context to use when recursing into a directory response.

public readonly IDirectoryLoaderContextHandler? ChildContext

Field Value

IDirectoryLoaderContextHandler

NodeTransformer

An optional node transformation function to apply to this node or directory.

public readonly Func<JsonNode?, JsonNode?>? NodeTransformer

Field Value

Func<JsonNode, JsonNode>

PropertyName

The name of the property in the parent JsonObject into which the response should be loaded.

public readonly string PropertyName

Field Value

string

Properties

Directory

The directory to recurse into.

public IFileSystemDirectory? Directory { get; }

Property Value

IFileSystemDirectory

IsDirectory

Is true if this is a directory response.

[MemberNotNullWhen(true, "Directory")]
[MemberNotNullWhen(false, "Node")]
public bool IsDirectory { get; }

Property Value

bool

IsNode

Is true if this is a node response.

[MemberNotNullWhen(true, "Node")]
[MemberNotNullWhen(false, "Directory")]
public bool IsNode { get; }

Property Value

bool

Remarks

The Node property can still be null when this is true because the convention used by System.Text.Json.Nodes to represent null JSON values is a .NET null reference.

Node

The JSON node in the response. May be null if this is a directory response or a null JSON value.

public JsonNode? Node { get; }

Property Value

JsonNode