MX-Frame has built-in Expression Engine. Main purpose of the expression engine is to provide functionality for defining various values in design time but evaluating them in run time. This enables developer much more flexibility. It is a common practice to know a rule, condition or a formula but in design time values for the parameters are not yet known or available. This is when expression engine shines in all its glory. Expression engine has also its own designer with which it is possible to define as expression text. All this is done in a developer friendly manner, using predefined functions and variables.
Expression Designer
Expression designer or expression editor is used for defining expressions throughout the whole development process. The editor is used for defining statement execution condition, field read only condition, value expression, etc. All conditions in MxDiagram component are also developed in Expression Editor. It offers wide variety of variables and functions which can be used to define custom expressions. Developer can choose from system and environment variables. Data defined in the same scope is also available for manipulation. Functions are defined for manipulation with variables and other data.
Expression designer consists of three main parts:
- Variables & Functions browser (VFB)
- Expression text editor
- Function description panel
Because we can set expression text on a wide range of properties, VFB can contain different items from case to case. Most often VFB will consist of:
- Settings variables, which are actually property pages.
- Data source variables, if VFB has access to MxAdapter at the point of defining expression.
- Functions collection.
One of the most interesting concepts of Expression engine is that we are able to define Property Page with different scope (System, Profile, Workplace, Workstation), then use any setting from that property page and Expression engine will always evaluate correct expression value. For example, let's say that we have Property Page named LocalSettings with scope Workstation and one setting LocalDatabasePath. We then set this setting in MX-Client for each workstation. Meanwhile, we set the following expression on ReadOnlyCondition of the schema field:
If(IsNull([Settings.LocalSettings.LocalDatabasePath], true, false))
That means that Expression will evaluate expression text against workstation on which MX-Client is running and will always gather correct value.
Another powerfull feature of the Expression engine is that we have access to the all data sources inside adapter, even more, if we are defining expression on some workflow condition, we have access to all adapters which are defined as variables. This way we can execute calculations over many data sources at the same time. Expression entities are loaded dynamically. This approach enables expression extensions. In other words, we can define our own functions and use them transparently within expression engine. Expression editor also contains environmental and login information. Therefore the expression can contain workstation information as well as username of currently logged user. Expression engine also supports arithmetic and logical operators such as addition, subtraction, multiplication, divide, equality compare, inequality, logical AND, logical OR, etc.
MxAdapter
Expression Designer