Any non-trivial application domain will require certain values to be calculated from other values (e.g. metadata values or values provided by external systems).
A model uses expressions to specify default values, calculated values, and to control UI states (e.g. visibility). Quino has a C#-style language, an AST and mapping to various subystems (e.g. the ORM).
An application represents such code with Quino Expressions.
This discussion includes the following sub-sections:
- Grammar: Describes the DSL for writing expressions
- Text Formatting: Describes the DSL for formatting text in expressions
- Expression Contexts: Providing and using information during evaluation
- Standard Functions: Standard functions for expressions (e.g.
- Custom Functions: Defining custom functions for expressions
- An application wants to determine the visibility of a property dynamically (e.g.
Address.Country != 'CH')
- An application wants to control the background color of a control (e.g.
Grade > 85)
- An application wants to base the value of a text field on other fields (e.g.
- An application wants to define a filter for a relation (e.g.
IsEmployee && IsManager && IsActive)
Quino provides the following support for expressions.
- AST: A set of
IExpressionnode that form an AST
- Factories: An
IExpressionFactoryto produce basic expression nodes and an
IMetaExpressionFactoryto produce expression nodes that reference
- Parser: An
IExpressionParserto process the text representation described in more detail below.
- Evaluation: An evaluation engine for determining the value of an expression
- Functions: Support for functions (e.g.
Trim) that can be easily extended by products
- Context: An
IExpressionContextprovides external context during evaluation (e.g. the
this.Persistedfunction references the
IDataObjectset in the context)
- ORM: ORM integration to map expressions to SQL. The standard operations are mapped as well as several functions (e.g.
Today). Products can easily provide mappings for custom functions for specific database dialects
The text representation is provided for convenience and expressiveness.
For example, the expression
Active && IsEmployee is easier to write than its AST equivalent, shown below.
factory.CreateBinaryOperator( factory.CreateProperty(metadata.Person.Active), ExpressionOperator.And, factory.CreateProperty(metadata.Person.IsEmployee) )
A very common use case is to represent text in way that accommodates missing data gracefully. For this, Quino's expression language includes a sub-language for text formatting.
Quino defines several sets of functions and provides a mechanism whereby a product can register its own.