Solution consist of following projects:
  • ExpressionEngine - contains all classes responsible for expression evaluating.
    • ExpressionEveluator - core of this library. This class converts infix expressions to postfix form and evaluates them. It supports only "plain" expressions (without aggregate functions). Also this class is independent from other classes in library, and can be used separately if you need just to evaluate some expression, like (X+Y)*Z. Exposes the following members:
      • Constructor - ExpressionEveluator(string) - accepts expression string as an argument.
      • Evaluate(IValueProvider) - evaluates expression and returns result. Argument IValueProvider - allows ExpressionEveluator to get actual variable values if some appears in your expression. But if expression does not contains any variables, for example (1+1)*2 this argument can be null.
    • AggregateExpressionEvaluator - derived from ExpressionEveluator, and this one supports aggregate functions. For now supported functions are: SUM, AVG, MAX, MIN, COUNT. To add your own one it's enough to create class derived from BaseAggregateFunction, and state class derived from BaseAggregateState. Then register this newly created aggregate function class in _aggregatedFunction - see private field of AggregateExpressionEvaluator. Exposes the following members:
      • Constructor AggregateExpressionEvaluator(string) - with expression as argument. This one can contains aggregate functions, for example - SUM(Column1Column2)AVG(Column3).
      • Reset() - you should call this function if you want to use single instance of AggregateExpressionEvaluator to evaluate expressions against deferment data sets.
      • RowChanged(IValueProvider valueProvider) - call this function for every row of your data. IValueProvider allows AggregateExpressionEvaluator to get field values for current row.
      • GetResult() - after all rows where passed through RowChanged method, you can call this one to get result.
  • ASPxGridViewExpressionSummary - integration with DevExpress ASPxGridView. Allows to write expression directly in grid definition tags:
        <cc1:ExpressionSummary FieldName="Column1" ShowInColumn="Column1" Expression="AVG(Column4/Column3)+SUM(Column3)"/>
  • ExpressionSummaryExtender - integration with XtraReports. Allows to associate expression with XRLabel controls located in applicable report bands.

Last edited Mar 10, 2013 at 9:31 PM by vol_bob, version 2


No comments yet.