Galaktikasoft

Expression. Getting Started

Getting Started

This topic explains how to implement the ExpressionObject business class, which allows demonstrating the functionality of the Xafari Expression Property Editor. Follow the steps described below.

Add a new Domain Component to the Module Project, name it ExpressionObject, declare the Expression and Type properties as follows:

[EditorAlias("ExpressionPropertyEditor")]
[CriteriaOptions("Type")]
string Expression { get; set; }

[ImmediatePostData]
[ValueConverter(typeof(TypeToStringConverter))]
Type Type { get; set; }

You can view the code used in this lesson in the Xafari.XtraEditors.Module | Editors| ExpressionObject.cs file of the Xafari XtraEditors demo installed with the product.

The EditorAlias attribute indicates, that the Expression property will be displayed via the ExpressionPropertyEditor. An alternative approach is to use the Model Editor.

Type property allows associating an expression with a context type. [CriteriaOptions("Type")] attribute decorates the Expression property, it means that the Type property specifies the context type for the expression. If the context type is null, then the Expression Editor does not display the metadata tree.

Note: To calculate the value of the expression it is necessary to use the GetValue method of the ExpressionCalculator static class:
ExpressionCalculator.GetValue(expression, context, parameters);