Class Expressions
Class providing functions for expression testing and evaluation
Inherited Members
Namespace: DuetControlServer.Model
Assembly: DuetControlServer.dll
Syntax
public static class Expressions
Properties
CustomFunctions
Dictionary of custom meta G-code functions vs. async resolvers
Declaration
public static Dictionary<string, Expressions.CustomAsyncFunctionResolver> CustomFunctions { get; }
Property Value
Type | Description |
---|---|
Dictionary<string, Expressions.CustomAsyncFunctionResolver> |
Methods
ContainsSbcFields(Code)
Checks if the given code contains any SBC object model fields
Declaration
public static bool ContainsSbcFields(Code code)
Parameters
Type | Name | Description |
---|---|---|
Code | code | Code to check |
Returns
Type | Description |
---|---|
bool | Whether the code contains any SBC object model fields |
Exceptions
Type | Condition |
---|---|
CodeParserException | Failed to parse expression |
Evaluate(Code, bool)
Evaluate a conditional code
Declaration
public static Task<string?> Evaluate(Code code, bool evaluateAll)
Parameters
Type | Name | Description |
---|---|---|
Code | code | Code holding expressions |
bool | evaluateAll | Whether all or only SBC fields are supposed to be evaluated |
Returns
Type | Description |
---|---|
Task<string> | Evaluation result or null |
EvaluateExpression(Code, string, bool, bool)
Evaluate expression(s)
Declaration
public static Task<string> EvaluateExpression(Code code, string expression, bool onlySbcFields, bool encodeResult)
Parameters
Type | Name | Description |
---|---|---|
Code | code | Code holding the expression(s) |
string | expression | Expression(s) to replace |
bool | onlySbcFields | Whether to replace only SBC fields |
bool | encodeResult | Whether the final result shall be encoded |
Returns
Type | Description |
---|---|
Task<string> | Replaced expression(s) |
Exceptions
Type | Condition |
---|---|
CodeParserException | Failed to parse expression(s) |
OperationCanceledException | Code was cancelled |
EvaluateExpressionRaw(Code, string, bool)
Evaluate expression(s) and return the raw evaluation result (if applicable)
Declaration
public static Task<object?> EvaluateExpressionRaw(Code code, string expression, bool onlySbcFields)
Parameters
Type | Name | Description |
---|---|---|
Code | code | Code holding the expression(s) |
string | expression | Expression(s) to replace |
bool | onlySbcFields | Whether to replace only SBC fields |
Returns
Type | Description |
---|---|
Task<object> | Replaced expression(s) |
Exceptions
Type | Condition |
---|---|
CodeParserException | Failed to parse expression(s) |
OperationCanceledException | Code was cancelled |
IsSbcExpression(string, bool)
Checks if the given expression without indices is a SBC object model field
Declaration
public static bool IsSbcExpression(string expression, bool isFunction)
Parameters
Type | Name | Description |
---|---|---|
string | expression | Expression without indices to check |
bool | isFunction | Expression is followed by an opening brace, check only if it is a custom function |
Returns
Type | Description |
---|---|
bool | Whether the given expression is a SBC object model field |