Class If
- Namespace
- BotManager.Runtime.Expressions
- Assembly
- BotManager.Runtime.dll
Executes the Then expression if Condition returns true.
Otherwise Else is executed.
Returns the value of the executed branch.
10:
{ "$If": { "Condition": true, "Then": 10, "Else": 20 } }
This json example returns 20:
{ "$If": { "Condition": false, "Then": 10, "Else": 20 } }
public sealed class If : IExpression
- Inheritance
-
If
- Implements
- Inherited Members
Constructors
If()
public If()
Properties
Condition
Gets and sets the condition to check.
public IExpression? Condition { get; set; }
Property Value
Else
Gets and sets the operation if the condition is false.
public IExpression? Else { get; set; }
Property Value
Then
Gets and sets the operation if the condition is true.
public IExpression? Then { get; set; }
Property Value
Methods
ExecuteAsync(RuntimeContext, Type?)
Executes the expression in the given RuntimeContext. Please do not use this method to run an expression. Use ExecuteAsync(IExpression?) instead.
public 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.