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
Properties
Types
Returns a list of all registered expression types.
public static IEnumerable<Type> Types { get; }
Property Value
Methods
Deserialize(Stream)
Deserialize the given json stream to an IExpression.
public static IExpression? Deserialize(Stream stream)
Parameters
streamStreamThe input json stream.
Returns
Deserialize(string)
Deserialize the given json file to an IExpression.
public static IExpression? Deserialize(string fileName)
Parameters
fileNamestringThe path to the json file.
Returns
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
contextRuntimeContextThe current runtime context.
returnTypeTypeThe expected return type. Use
typeof(object)for a generic result. Usenullif you don't need the return value.
Returns
RegisterExpression(Type)
Registers a new type for the serializer.
public static void RegisterExpression(Type type)
Parameters
typeTypeThe expression type to register.
RegisterExpression<T>()
Registers a new type for the serializer.
public static void RegisterExpression<T>() where T : IExpression
Type Parameters
TThe 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
assemblyAssemblyThe assembly to scan for expressions.
Serialize(Stream, IExpression)
Serializes an IExpression to a json stream.
public static void Serialize(Stream stream, IExpression expression)
Parameters
streamStreamThe output json stream.
expressionIExpressionThe 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
Returns
- bool
Returns
trueif a type was found.