Search Results for

    Show / Hide Table of Contents

    Class ScriptHelper

    A helper class for evaluating scripts and formulas in LemonEdge

    Inheritance
    object
    ScriptHelper
    Implements
    IScriptHelper
    Inherited Members
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    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 formula against the provuded context

    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 formula against the provuded context

    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 formula against the provided context

    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

    Implements

    IScriptHelper

    Extension Methods

    LinqExtensions.AsArray<T>(T)
    LinqExtensions.ToArrayOfOne<T>(T)
    LinqExtensions.ToListOfOne<T>(T)
    MiscExtensions.SetIfNotEqual<T, TP>(T, Expression<Func<T, TP>>, TP)
    WeakReferenceExtensions.WeakReference(object)
    SQLExtensions.ToSQLValue(object, bool)
    ReflectionExtensions.ClearEventInvocations(object, string)
    StringExtensions.ToCSVFormatString(object, Type)
    In this article
    Back to top © LemonEdge Technologies. All rights reserved.