Class ScriptHelper
A helper class for evaluating scripts and formulas in LemonEdge
Implements
Inherited Members
Namespace: LemonEdge.API.Core.Scripting
Assembly: LemonEdge.API.dll
Syntax
public class ScriptHelper : IScriptHelper
Constructors
ScriptHelper(ICodeBuilder, HelperImplementation, IOptions<DeveloperSettings>)
Declaration
public ScriptHelper(ICodeBuilder codeBuilder, HelperImplementation helperImplementation, IOptions<DeveloperSettings> developerSettings)
Parameters
Type | Name | Description |
---|---|---|
ICodeBuilder | codeBuilder | |
HelperImplementation | helperImplementation | |
IOptions<DeveloperSettings> | developerSettings |
Properties
Instance
Declaration
public static IScriptHelper Instance { get; set; }
Property Value
Type | Description |
---|---|
IScriptHelper |
Methods
EvaluateFormulaType(string, Type, object)
Evaluates the specified formula
and returns the result as the specified
resultType
The script can take a context
that can be referenced in the formula, and must be of type
contextType
Declaration
public Task<object> EvaluateFormulaType(string formula, Type contextType, object context)
Parameters
Type | Name | Description |
---|---|---|
string | formula | The formula, or script, to be parsed and evaluated |
Type | contextType | The type of the context object that can be referenced by the formula or script |
object | context | The context object that can be referenced by the formula or script |
Returns
Type | Description |
---|---|
Task<object> | The result of evaluating the specified |
EvaluateFormulaType(Type, string, Type, object)
Evaluates the specified formula
and returns the result as the specified
resultType
The script can take a context
that can be referenced in the formula, and must be of type
contextType
Declaration
public Task<object> EvaluateFormulaType(Type resultType, string formula, Type contextType, object context)
Parameters
Type | Name | Description |
---|---|---|
Type | resultType | The type of the result returned from this formula or script |
string | formula | The formula, or script, to be parsed and evaluated |
Type | contextType | The type of the context object that can be referenced by the formula or script |
object | context | The context object that can be referenced by the formula or script |
Returns
Type | Description |
---|---|
Task<object> | The result of evaluating the specified |
EvaluateFormula<T>(string, Type, object, bool)
Evaluates the specified formula
and returns the result as the specified
T
The script can take a context
that can be referenced in the formula, and must be of type
contextType
Declaration
public Task<T> EvaluateFormula<T>(string formula, Type contextType, object context, bool compileOnly = false)
Parameters
Type | Name | Description |
---|---|---|
string | formula | The formula, or script, to be parsed and evaluated |
Type | contextType | The type of the context object that can be referenced by the formula or script |
object | context | The context object that can be referenced by the formula or script |
bool | compileOnly | Whether to just compile the script for the purpose of initialisation, or also execute it. |
Returns
Type | Description |
---|---|
Task<T> | The result of evaluating the specified |
Type Parameters
Name | Description |
---|---|
T | The type of the result returned from this formula or script |
IsValid<T>(string, Type)
Throws an error with any compilation exceptions
Declaration
public bool IsValid<T>(string formula, Type contextType)
Parameters
Type | Name | Description |
---|---|---|
string | formula | |
Type | contextType |
Returns
Type | Description |
---|---|
bool |
Type Parameters
Name | Description |
---|---|
T |