expression tree

Post on 10-May-2015

175 views 0 download

description

Expression Tree presented by Drake @20121207

Transcript of expression tree

Expression Tree

drake

Expression

• 3• a• !a• a+b• Math.Sin(a)• new StringBuilder()

Expression

• 3 ConstantExpression• aParameterExpression• !aUnaryExpression• a+bBinaryExpression• Math.Sin(a)MethodCallExpression• new StringBuilder()NewExpression

Summary

• 運算式的一個重要的特點就是它可以無限地組合,只要符合正確的類型和語義

• +可以用於各類數數值型別的加法,那麼加號的左右就可以是任何類型為相應數值的表達式

Example

• a + 2 + 3• (a + 2) => b, (b+3)

Example

• Math.Sin(a) + 3

Expression

• System.Linq.Expressions1+2+3

Usage

System.Linq.Expressions.Expression

Expressioin

• Math.Sin(a)

Usage

Lambda Expression

• (parameters) => expression

Usage

InvocationExpression

Usage

Expression.OrElse Method

Usage

Using PredicateBuilder

PredicateBuilder Source Code

• Thank you for your listening!