VariableStore Class#
Thread-safe IVariableStore backed by a System.Collections.Concurrent.ConcurrentDictionary<>.
public sealed class VariableStore : Verso.Abstractions.IVariableStore
Inheritance System.Object → VariableStore
Implements IVariableStore
Methods#
Clear() Method#
Removes all variables from the store.
public void Clear();
Implements Clear()
Get<T>(string) Method#
Retrieves a variable by name, casting it to the specified type.
public 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.
Implements Get<T>(string)
Returns#
T
The variable value cast to T, or default if not found.
GetAll() Method#
Returns descriptors for all variables currently stored.
public System.Collections.Generic.IReadOnlyList<Verso.Abstractions.VariableDescriptor> GetAll();
Implements 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.
public bool Remove(string name);
Parameters#
name System.String
The name of the variable to remove.
Implements Remove(string)
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.
public void Set(string name, object value);
Parameters#
name System.String
The name of the variable.
value System.Object
The value to store.
Implements Set(string, object)
TryGet<T>(string, T) Method#
Attempts to retrieve a variable by name, casting it to the specified type.
public 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.
Implements TryGet<T>(string, T)
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).
public event Action? OnVariablesChanged;
Implements OnVariablesChanged