Table of Contents

Interface IExpression

Namespace
BotManager.Runtime
Assembly
BotManager.Runtime.dll

The expression interface defines one operation that can be serialized in a json file. Use the RuntimeContext to execute these expressions.

[JsonConverter(typeof(ExpressionConverter))]
public interface IExpression

Fields

SerializerOptions

Gets the default json serializer options for the expression interface.

public static readonly JsonSerializerOptions SerializerOptions

Field Value

JsonSerializerOptions

Properties

Types

Returns a list of all registered expression types.

public static IEnumerable<Type> Types { get; }

Property Value

IEnumerable<Type>

Methods

Deserialize(Stream)

Deserialize the given json stream to an IExpression.

public static IExpression? Deserialize(Stream stream)

Parameters

stream Stream

The input json stream.

Returns

IExpression

Deserialize(string)

Deserialize the given json file to an IExpression.

public static IExpression? Deserialize(string fileName)

Parameters

fileName string

The path to the json file.

Returns

IExpression

ExecuteAsync(RuntimeContext, Type?)

Executes the expression in the given RuntimeContext. Please do not use this method to run an expression. Use ExecuteAsync(IExpression?) instead.

Task<object?> ExecuteAsync(RuntimeContext context, Type? returnType)

Parameters

context RuntimeContext

The current runtime context.

returnType Type

The expected return type. Use typeof(object) for a generic result. Use null if you don't need the return value.

Returns

Task<object>

Returns the result of the expression.

RegisterExpression(Type)

Registers a new type for the serializer.

public static void RegisterExpression(Type type)

Parameters

type Type

The expression type to register.

RegisterExpression<T>()

Registers a new type for the serializer.

public static void RegisterExpression<T>() where T : IExpression

Type Parameters

T

The expression type to register.

RegisterExpressionsFromAssembly(Assembly)

Registers all public IExpression types from the serializer in the given assembly.

public static void RegisterExpressionsFromAssembly(Assembly assembly)

Parameters

assembly Assembly

The assembly to scan for expressions.

Serialize(Stream, IExpression)

Serializes an IExpression to a json stream.

public static void Serialize(Stream stream, IExpression expression)

Parameters

stream Stream

The output json stream.

expression IExpression

The expression to serialize.

TryGetExpressionInfo(string, out Type)

Tries to gets a registered schema by it's name.

public static bool TryGetExpressionInfo(string typeName, out Type type)

Parameters

typeName string

The name of the type.

type Type

The returned type.

Returns

bool

Returns true if a type was found.