Function Class

Assembly: CodeEffects.Rule.Editor.dll
Namespace: CodeEffects.Rule.Editor.Client

Summary

Represents an in-rule method or an action of the source object in an Adaptive Source. A source holds its methods in the Functions property and its actions in the Actions property of Source. The class carries the same information as the MethodAttribute and ActionAttribute do in a source object class.

Syntax

public class Function : Item, ISettable, IFilterable

Function inherits DisplayName, Value, Description, AiAliases, AiDescription, Nullable, and ResetsContext from Item.

Constructors

  • Function()

    Creates a function with no parameters, a new Return, and a new Settings. IncludeInCalculations, IncludeInConcatenations, and Gettable are true.

Properties

  • IncludeInCalculations

    Type: System.Boolean

    For methods that return a number: whether users can use the method in calculations of other elements. The default value is true.

  • IncludeInConcatenations

    Type: System.Boolean

    For methods that return a string: whether users can use the method in concatenations of other elements. The default value is true.

  • Gettable

    Type: System.Boolean

    Indicates whether the method can be used in the condition section of a rule. The default value is true.

  • Filter

    Type: System.String

    Implements IFilterable. The filter value of the function.

  • Group

    Type: System.String

    The name of the group the Rule Editor shows the function under in its menus.

  • Settings

    Type: Settings

    Implements ISettable. The settings of the function.

  • Parameters

    Type: IList<Parameter>

    The parameters of the function, in the order of the method's signature. The default value is an empty list.

  • Return

    Type: Return

    The return value of the function. An action has no return value to use, so leave it at its default.

  • TestMethodName

    Type: System.String

    The name of the method the Code Effects Rule Repository calls instead of this one when it tests a rule. An instance test method of the evaluated object's own class is called on that object and takes only this method's parameters from the rule. Any other test method takes the object first, then those parameters (a source parameter is not repeated). Ignored outside a test.

  • TestMethodType

    Type: System.String

    The class, or the alias that the host's type resolver knows, that declares the test method named by TestMethodName. When it is not set, the class that declares this method is used.

Methods

  • ToString(bool isAdaptiveSource)

    Returns: System.String

    Returns the function as the JSON object that the Rule Editor sends to the client. The Rule Editor calls this method; you do not need to.

Example

using CodeEffects.Rule.Common.Models;
using CodeEffects.Rule.Editor.Client;

var method = new Function
{
	Value = "IsWeekend",
	DisplayName = "Is Weekend",
	Return = new Return { DataType = DataType.Bool }
};

method.Parameters.Add(new Parameter { DataType = DataType.Date, Description = "The date to check" });

Ask on Stack Overflow - Yes, it's still active
Ask in GitHub Discussions

p102

l097 --

l102

p101

×