Docs · API reference · Verso.Contexts

ExecutionContext Class#

IExecutionContext implementation extending VersoContext with cell-specific execution state and display output routing.

public sealed class ExecutionContext : Verso.Contexts.VersoContext, Verso.Abstractions.IExecutionContext, Verso.Abstractions.IVersoContext

Inheritance System.Object → VersoContext → ExecutionContext

Implements IExecutionContext, IVersoContext

Constructors#

ExecutionContext(Guid, int, IVariableStore, CancellationToken, IThemeContext, LayoutCapabilities, IExtensionHostContext, INotebookMetadata, INotebookOperations, Func<CellOutput,Task>, Func<CellOutput,Task>, Func<string,bool,CancellationToken,Task<string>>) Constructor#

Builds a context with no in-place output updating, which is what a host that cannot revise an output provides.

public ExecutionContext(System.Guid cellId, int executionCount, Verso.Abstractions.IVariableStore variables, System.Threading.CancellationToken cancellationToken, Verso.Abstractions.IThemeContext theme, Verso.Abstractions.LayoutCapabilities layoutCapabilities, Verso.Abstractions.IExtensionHostContext extensionHost, Verso.Abstractions.INotebookMetadata notebookMetadata, Verso.Abstractions.INotebookOperations notebook, System.Func<Verso.Abstractions.CellOutput,System.Threading.Tasks.Task> writeOutput, System.Func<Verso.Abstractions.CellOutput,System.Threading.Tasks.Task> display, System.Func<string,bool,System.Threading.CancellationToken,System.Threading.Tasks.Task<string?>>? requestInput=null);

Parameters#

cellId System.Guid

executionCount System.Int32

variables IVariableStore

cancellationToken System.Threading.CancellationToken

theme IThemeContext

layoutCapabilities LayoutCapabilities

extensionHost IExtensionHostContext

notebookMetadata INotebookMetadata

notebook INotebookOperations

writeOutput System.Func<CellOutput,System.Threading.Tasks.Task>

display System.Func<CellOutput,System.Threading.Tasks.Task>

requestInput System.Func<System.String,System.Boolean,System.Threading.CancellationToken,System.Threading.Tasks.Task<System.String>>

Remarks#

Kept as its own overload rather than folded into the one below. An optional parameter is resolved where the call is compiled, so adding one to a shipped constructor changes the signature every existing compiled caller looks for.

Properties#

CellId Property#

Gets the unique identifier of the cell being executed.

public System.Guid CellId { get; }

Implements CellId

Property Value#

System.Guid

ExecutionCount Property#

Gets the monotonically increasing execution counter for the current cell.

public int ExecutionCount { get; }

Implements ExecutionCount

Property Value#

System.Int32

Methods#

DisplayAsync(CellOutput) Method#

Sends a display output that can be updated in place during execution.

public System.Threading.Tasks.Task DisplayAsync(Verso.Abstractions.CellOutput output);

Parameters#

output CellOutput

The cell output to display.

Implements DisplayAsync(CellOutput)

Returns#

System.Threading.Tasks.Task
A task that completes when the output has been displayed.

RequestInputAsync(string, bool, CancellationToken) Method#

Requests a single line of user input from the current front-end.

public System.Threading.Tasks.Task<string?> RequestInputAsync(string prompt, bool isPassword=false, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters#

prompt System.String

Prompt text shown to the user.

isPassword System.Boolean

Whether the input should be masked.

cancellationToken System.Threading.CancellationToken

Cancellation token for the pending input request.

Implements RequestInputAsync(string, bool, CancellationToken)

Returns#

System.Threading.Tasks.Task<System.String>
The entered value, or null when the user cancels the prompt.

TryFormatAsync(object, IReadOnlyList<string>) Method#

Attempts to format a runtime value with a registered specialized data formatter. Returns null when no formatter claims the value so the language kernel can preserve its native formatting behavior.

public System.Threading.Tasks.Task<Verso.Abstractions.CellOutput?> TryFormatAsync(object value, System.Collections.Generic.IReadOnlyList<string>? acceptableMimeTypes=null);

Parameters#

value System.Object

The runtime value to format.

acceptableMimeTypes System.Collections.Generic.IReadOnlyList<System.String>

Optional MIME types the host can render, in descending order of preference.

Implements TryFormatAsync(object, IReadOnlyList<string>)

Returns#

System.Threading.Tasks.Task<CellOutput>