Table of Contents

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

original RuntimeContext

The 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

IDateTimeProvider

Functions

The map of local functions.

public Storage<IExpression> Functions { get; }

Property Value

Storage<IExpression>

Locals

The map of local variables.

public Storage<object> Locals { get; }

Property Value

Storage<object>

Logger

Gets the logger.

public Logger Logger { get; }

Property Value

Logger

RootPath

Gets and sets the root path of the current config file.

public string? RootPath { get; set; }

Property Value

string

Methods

ExecuteAsync(IExpression?)

Execute the given expression but don't expect any return value.

public Task ExecuteAsync(IExpression? expression)

Parameters

expression IExpression

The 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

expression IExpression

The expression to run.

returnType Type

The type of the return value.

Returns

Task<object>

ExecuteAsync<T>(IExpression?)

Execute the given expression with the given return type restriction.

public Task<T?> ExecuteAsync<T>(IExpression? expression)

Parameters

expression IExpression

The expression to run.

Returns

Task<T>

Returns the result of the expression.

Type Parameters

T

The type of the return value.

Get(string)

Gets a local variable by its name.

public object Get(string name)

Parameters

name string

The name of the variable.

Returns

object

Returns the value.

Set(string, object?)

Sets a local variable.

public void Set(string name, object? value)

Parameters

name string

The name of the variable.

value object

The value to set.