Posted by: emitsorgroup | August 29, 2011

Journey of a Windows Phone 7 application (from ideas to deployment) – Part IV: Expressions evaluation

As you create applications with InputStudio, for sure any application you create may need to execute some code at objects creation, update or saving. InputStudio allows you to provide some code snippets to your applications in the way of Business Rules objects as code expressions.

All Business Rules (expressions) must have a name, the actual code expression and when they will be applied (at creation, update or saving).

code expression

The code expression itself is build up from the attribute name, a mathematical operator and the actual value.

As you can infer from this, any code expression is the assignment of a value to an attribute. The actual attribute names are automatically filled up by InputStudio so, you just have to pick one from the list.

As you noted from the operators screenshot (below image) you can also use operator + equals which means the attribute will be sum/substract/multiplied/divided/modulus to its current value.




In the construction of this code expressions InputStudio helps you by discovering your data entities and its attributes and by suggesting them in the expressions list picker. This feature helps you a lot since you don’t have to know and type each of your data entities and its attributes. Also, some other available methods or properties of your data entities (inherited from its base class) are suggested like:

  • <DataEntity>.Children.Count
  • <DataEntity>.Children[ordinalIndex].<Attribute>
  • <DataEntity>.ChildrenAverage!<Attribute>
  • <DataEntity>.ChildrenMin!<Attribute>
  • <DataEntity>.ChildrenMax!<Attribute>
  • <DataEntity>.ChildrenSum!<Attribute>
    • Where:
      • <DataEntity> is your actual data entity name
      • ordinalIndex is a numeric index number
      • <Attribute> is your actual attribute name
      • Average, Min, Max and Sum are aggregate functions which calculate its values based on the data entity children objects.
expressions list

expressions list

While you can just select from the available objects, methods or properties, you can also type any other mathematical expression made up from numeric constant values or a mix of available object attributes multiplied, sum, subtracted or divided by some constant value or another object attribute.

The Gold Parser.

Note:  Following screen-shots and code, explain a little bit how the evaluation of expressions was accomplished in InputStudio. For your actual code snippets you don’t need this.

To help with the evaluation of these expressions, the Gold Parser library arrives to the Windows Phone 7. The Gold parser library requires a grammar, previously compiled with the Gold Parser Builder.



grammar - contd

grammar – contd

grammar productions

grammar productions

grammar productions - contd

grammar productions – contd



Then some helper code implements that grammar which at the end evaluates the Business Rules expressions.




Test expressions code testing in InputStudio project.

code test for expressions

code test for expressions

code test for expressions - contd

code test for expressions – contd

That is it for now, hope this post gives you an insight on the grammar you can use when coding your Business Rules snippets.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: