Docs · API reference · Verso.Abstractions

IVariableStore Interface#

Provides shared variable storage for exchanging data between kernels within a notebook session.

public interface IVariableStore

Methods#

Clear() Method#

Removes all variables from the store.

void Clear();

Get<T>(string) Method#

Retrieves a variable by name, casting it to the specified type.

T? Get<T>(string name);

Type parameters#

T

The expected type of the variable.

Parameters#

name System.String

The name of the variable to retrieve.

Returns#

T
The variable value cast to T, or default if not found.

GetAll() Method#

Returns descriptors for all variables currently stored.

System.Collections.Generic.IReadOnlyList<Verso.Abstractions.VariableDescriptor> GetAll();

Returns#

System.Collections.Generic.IReadOnlyList<VariableDescriptor>
A read-only list of VariableDescriptor instances describing each stored variable.

Remove(string) Method#

Removes a variable by name.

bool Remove(string name);

Parameters#

name System.String

The name of the variable to remove.

Returns#

System.Boolean
true if the variable was found and removed; otherwise, false.

Set(string, object) Method#

Stores a variable with the specified name, replacing any existing variable with the same name.

void Set(string name, object value);

Parameters#

name System.String

The name of the variable.

value System.Object

The value to store.

TryGet<T>(string, T) Method#

Attempts to retrieve a variable by name, casting it to the specified type.

bool TryGet<T>(string name, out T? value);

Type parameters#

T

The expected type of the variable.

Parameters#

name System.String

The name of the variable to retrieve.

value T

When this method returns, contains the variable value if found; otherwise, default.

Returns#

System.Boolean
true if the variable was found and successfully cast; otherwise, false.

Events#

OnVariablesChanged Event#

Raised when the variable store contents change (after Set, Remove, or Clear).

event Action? OnVariablesChanged;

Event Type#

System.Action