CommandDescriptor class

Namespace Runic.Application.Views.Generated in Runic.Application.Views 0.23.0

public sealed class CommandDescriptor

Describes one bridged command. Created by generated bridges.

Parameters

name

The command property name.

get

Reads the command object from the ViewModel.

Remarks

Generated code sets the members a command needs with an object initializer, so a later release can add a member without changing the constructor.

Constructors

CommandDescriptor

public CommandDescriptor(string name, Func<object, object> get)

Describes one bridged command. Created by generated bridges.

Parameters

name

The command property name.

get

Reads the command object from the ViewModel.

Remarks

Generated code sets the members a command needs with an object initializer, so a later release can add a member without changing the constructor.

Properties

CanExecute

public Func<object, object?, bool>? CanExecute { get; init; }

Evaluates whether the command can run with an argument.

Close

public RunicOperationClose Close { get; init; }

What a Window's close does to the command's running operations, from RunicOperationCloseAttribute. RunicOperationClose.Default by default.

CreateStream

public Func<BridgeOperationStream>? CreateStream { get; init; }

Creates the result stream of a streaming command.

EncodeArgument

public Func<object?, string>? EncodeArgument { get; init; }

Encodes the argument for diagnostics and replay checks.

EncodeFailure

public Func<object, string?>? EncodeFailure { get; init; }

Encodes the value of a RunicFailureException when it is the command's declared failure type, and returns null otherwise. null when the command declares no failure.

ExecuteAsync

public Func<object, CancellationToken, object?, Task>? ExecuteAsync { get; init; }

Executes a command without a result.

ExecuteResultAsync

public Func<object, CancellationToken, object?, Task<BridgeOperationResult>>? ExecuteResultAsync { get; init; }

Executes a command that produces a result.

ExecuteStreamAsync

public Func<object, BridgeOperationExecution, CancellationToken, object?, Task<BridgeOperationResult>>? ExecuteStreamAsync { get; init; }

Executes a streaming command.

Get

public Func<object, object> Get { get; }

Reads the command object from the ViewModel.

Name

public string Name { get; }

The command property name.

ObserveFailures

public Func<object, ILogger, IDisposable>? ObserveFailures { get; init; }

Observes the failures that the command reports outside a Bridge call's reply, such as a ReactiveUI command's ThrownExceptions, while a Bridge presents the ViewModel. The Bridge passes its logger, which writes to the Window's ILoggerFactory, and disposes the result when it detaches. null when the command reports its failures only to its caller.

ReadInput

public Func<JsonElement, object?>? ReadInput { get; init; }

Decodes the request's input, or null for a command without an input. It throws FormatException, JsonException, ArgumentException or OverflowException for an input that is not valid.

ResolveArgument

public Func<object, object?, object?>? ResolveArgument { get; init; }

Resolves the decoded wire key of a RunicCommandKeyAttribute command to the command's parameter in the Bridge call's model turn, or returns null when the key names no object. null for a command whose argument is its parameter.

ResolveArgumentAsync

public Func<object, object?, CancellationToken, ValueTask<object?>>? ResolveArgumentAsync { get; init; }

Resolves the decoded wire key of a RunicCommandKeyAttribute command to the command's parameter asynchronously, or returns null when the key names no object. It starts in the Bridge call's model turn; availability and execution run in a new turn. null unless the resolver is asynchronous.

Retirement

public RunicOperationRetirement Retirement { get; init; }

What happens to the command's running operations when the navigation entry whose content started them retires, from RunicOperationRetirementAttribute. RunicOperationRetirement.Keep by default.

Subscribe

public Func<object, Action, IDisposable>? Subscribe { get; init; }

Observes changes of the command's executability.

WireName

public string? WireName { get; init; }

The command's wire name, such as save; null uses CommandDescriptor.Name with a lowercase first character.