Extend Functionality

Parameters

A parameter is a named value that is available for use in expressions, it stores in the ParametersDictionary collection. in the process of functioning of the system of values may change. Xafari Expression Property Editor exposes two events to access parameters:

  • CollectParameters: it collects parameter names and descriptions.
  • CollectParametersValues: maps the parameter name and its value when debugging formulas.

The code snippet below demonstrates how to fill the collection parameters using a controller.

Note: GetValue method of the ExpressionCalculator static class calculates value according to the formula. The GetValue method has optional parameter Parameters:

Add Function

The developer of the business application can implement his own functions to extend the set of the built-in functions available in the Xafari Expression Property Editor. The custom function is a class implementing the ICustomFunctionOperatorBrowsable interface. Once a custom function is declared, you need to register it in your application using the CriteriaOperator.RegisterCustomFunction static method.

The following example shows, how to implement and the AddNumbersFunction function, which returns the sum of two numbers passed as parameters.

Implementation:

Registration in Module.cs: