Table of Contents

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.

This json example returns 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

IExpression

Else

Gets and sets the operation if the condition is false.

public IExpression? Else { get; set; }

Property Value

IExpression

Then

Gets and sets the operation if the condition is true.

public IExpression? Then { get; set; }

Property Value

IExpression

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

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.