Class RuntimeContext
- Namespace
- BotManager.Runtime
- Assembly
- BotManager.Runtime.dll
The runtime context stores variables for a IExpression run. Use ExecuteAsync(IExpression?) to run an expression.
public sealed class RuntimeContext
- Inheritance
-
RuntimeContext
- Inherited Members
Constructors
RuntimeContext()
Creates a new empty runtime context.
public RuntimeContext()
RuntimeContext(RuntimeContext)
Creates a copy of the original runtime. Use this if you plan to run expression outside the
current stack. Otherwise multiple expression can mess with the data in parallel.
public RuntimeContext(RuntimeContext original)
Parameters
originalRuntimeContextThe original context to copy from.
Properties
DateTimeProvider
Gets and sets the date time provider for the current runtime.
public IDateTimeProvider DateTimeProvider { get; set; }
Property Value
Functions
The map of local functions.
public Storage<IExpression> Functions { get; }
Property Value
Locals
The map of local variables.
public Storage<object> Locals { get; }
Property Value
Logger
Gets the logger.
public Logger Logger { get; }
Property Value
RootPath
Gets and sets the root path of the current config file.
public string? RootPath { get; set; }
Property Value
Methods
ExecuteAsync(IExpression?)
Execute the given expression but don't expect any return value.
public Task ExecuteAsync(IExpression? expression)
Parameters
expressionIExpressionThe expression to run.
Returns
- Task
The task without any return value.
ExecuteAsync(IExpression?, Type?)
Execute the given operation with the given return type restriction.
public Task<object?> ExecuteAsync(IExpression? expression, Type? returnType)
Parameters
expressionIExpressionThe expression to run.
returnTypeTypeThe type of the return value.
Returns
ExecuteAsync<T>(IExpression?)
Execute the given expression with the given return type restriction.
public Task<T?> ExecuteAsync<T>(IExpression? expression)
Parameters
expressionIExpressionThe expression to run.
Returns
- Task<T>
Returns the result of the expression.
Type Parameters
TThe type of the return value.
Get(string)
Gets a local variable by its name.
public object Get(string name)
Parameters
namestringThe name of the variable.
Returns
- object
Returns the value.
Set(string, object?)
Sets a local variable.
public void Set(string name, object? value)