Class ExpressionBuilder
Provides extension methods to simplify construction of complex expressions.
Namespace: DotNext.Linq.Expressions
Assembly: DotNext.Metaprogramming.dll
Syntax
public static class ExpressionBuilder : object
Methods
| Improve this Doc View SourceAdd(Expression, Expression)
Constructs binary arithmetic addition expression.
Declaration
public static BinaryExpression Add(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The left operand. |
Expression | right | The right operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a + b
And(Expression, Expression)
Constructs binary logical AND expression.
Declaration
public static BinaryExpression And(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The left operand. |
Expression | right | The right operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a & b
AndAlso(Expression, Expression)
Constructs binary expression that represents a conditional AND operation that evaluates the second operand only if the first operand evaluates to true.
Declaration
public static BinaryExpression AndAlso(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The first operand. |
Expression | right | The second operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a && b
.
ArrayLength(Expression)
Constructs array length expression.
Declaration
public static UnaryExpression ArrayLength(this Expression array)
Parameters
Type | Name | Description |
---|---|---|
Expression | array | The array expression. |
Returns
Type | Description |
---|---|
UnaryExpression | Array length expression. |
Remarks
The equivalent code is a.LongLength
.
Assign(IndexExpression, Expression)
Constructs assignment expression.
Declaration
public static BinaryExpression Assign(this IndexExpression left, Expression value)
Parameters
Type | Name | Description |
---|---|---|
IndexExpression | left | The assignee. |
Expression | value | The value to be assigned to the left expression. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a.b[i] = c
.
Assign(MemberExpression, Expression)
Constructs assignment expression.
Declaration
public static BinaryExpression Assign(this MemberExpression left, Expression value)
Parameters
Type | Name | Description |
---|---|---|
MemberExpression | left | The assignee. |
Expression | value | The value to be assigned to the left expression. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a.member = b
.
Assign(ParameterExpression, Expression)
Constructs assignment expression.
Declaration
public static BinaryExpression Assign(this ParameterExpression left, Expression value)
Parameters
Type | Name | Description |
---|---|---|
ParameterExpression | left | The assignee. |
Expression | value | The value to be assigned to the left expression. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a = b
.
AssignDefault(IndexExpression)
Constructs assignment expression.
Declaration
public static BinaryExpression AssignDefault(this IndexExpression left)
Parameters
Type | Name | Description |
---|---|---|
IndexExpression | left | The assignee. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a.member[i] = default(T)
.
AssignDefault(MemberExpression)
Constructs assignment expression.
Declaration
public static BinaryExpression AssignDefault(this MemberExpression left)
Parameters
Type | Name | Description |
---|---|---|
MemberExpression | left | The assignee. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a.member = default(T)
.
AssignDefault(ParameterExpression)
Constructs assignment expression.
Declaration
public static BinaryExpression AssignDefault(this ParameterExpression left)
Parameters
Type | Name | Description |
---|---|---|
ParameterExpression | left | The assignee. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a = default(T)
.
AsString(Expression)
Constructs expression that calls
Declaration
public static MethodCallExpression AsString(this Expression obj)
Parameters
Type | Name | Description |
---|---|---|
Expression | obj | The object to be converted into string. |
Returns
Type | Description |
---|---|
MethodCallExpression | The expression representing |
Await(Expression, Boolean)
Constructs suspension point in the execution of the lambda function until the awaited task completes.
Declaration
public static AwaitExpression Await(this Expression expression, bool configureAwait = false)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression |
Boolean | configureAwait | true to call |
Returns
Type | Description |
---|---|
AwaitExpression | await expression. |
Remarks
The equivalent code is await b
.
See Also
| Improve this Doc View SourceBreak(LabelTarget)
Constructs loop leave statement.
Declaration
public static GotoExpression Break(this LabelTarget label)
Parameters
Type | Name | Description |
---|---|---|
LabelTarget | label | The label indicating loop exit. |
Returns
Type | Description |
---|---|
GotoExpression | Break statement. |
Remarks
The equivalent code is break
.
Break(LabelTarget, Expression)
Constructs loop leave statement.
Declaration
public static GotoExpression Break(this LabelTarget label, Expression value)
Parameters
Type | Name | Description |
---|---|---|
LabelTarget | label | The label indicating loop exit. |
Expression | value | The value to be returned from loop. |
Returns
Type | Description |
---|---|
GotoExpression | Break statement. |
Call(Expression, MethodInfo, Expression[])
Constructs instance method call expression.
Declaration
public static MethodCallExpression Call(this Expression instance, MethodInfo method, params Expression[] arguments)
Parameters
Type | Name | Description |
---|---|---|
Expression | instance |
|
MethodInfo | method | The method to be called. |
Expression[] | arguments | The method arguments. |
Returns
Type | Description |
---|---|
MethodCallExpression | The method call expression. |
Remarks
The equivalent code is obj.Method(a, b,...)
.
Call(Expression, String, Expression[])
Constructs instance method call expression.
Declaration
public static MethodCallExpression Call(this Expression instance, string methodName, params Expression[] arguments)
Parameters
Type | Name | Description |
---|---|---|
Expression | instance |
|
String | methodName | The name of the method to be called. |
Expression[] | arguments | The method arguments. |
Returns
Type | Description |
---|---|
MethodCallExpression | The method call expression. |
Remarks
The equivalent code is obj.Method()
.
Call(Expression, Type, String, Expression[])
Constructs interface or base class method call expression.
Declaration
public static MethodCallExpression Call(this Expression instance, Type interfaceType, string methodName, params Expression[] arguments)
Parameters
Type | Name | Description |
---|---|---|
Expression | instance |
|
Type | interfaceType | The interface or base class. |
String | methodName | The name of the method in the interface or base class to be called. |
Expression[] | arguments | The method arguments. |
Returns
Type | Description |
---|---|
MethodCallExpression | The method call expression. |
Remarks
The equivalent code is ((T)obj).Method()
.
CallStatic(Type, String, Expression[])
Constructs static method call.
Declaration
public static MethodCallExpression CallStatic(this Type type, string methodName, params Expression[] arguments)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type that declares static method. |
String | methodName | The name of the static method. |
Expression[] | arguments | The arguments to be passed into static method. |
Returns
Type | Description |
---|---|
MethodCallExpression | An expression representing static method call. |
Concat(Expression, Expression[])
Constructs string concatenation expression.
Declaration
public static MethodCallExpression Concat(this Expression first, params Expression[] other)
Parameters
Type | Name | Description |
---|---|---|
Expression | first | The first string to concatenate. |
Expression[] | other | Other strings to concatenate. |
Returns
Type | Description |
---|---|
MethodCallExpression | An expression presenting concatenation. |
Condition(Expression, Expression, Expression, Type)
Constructs conditional expression.
Declaration
public static ConditionalExpression Condition(this Expression test, Expression ifTrue = null, Expression ifFalse = null, Type type = null)
Parameters
Type | Name | Description |
---|---|---|
Expression | test | Test expression. |
Expression | ifTrue | Positive branch. |
Expression | ifFalse | Negative branch. |
Type | type | The type of conditional expression. Default is |
Returns
Type | Description |
---|---|
ConditionalExpression | Conditional expression. |
Remarks
The equivalent code is a ? b : c
.
Condition<R>(Expression, Expression, Expression)
Constructs conditional expression.
Declaration
public static ConditionalExpression Condition<R>(this Expression test, Expression ifTrue, Expression ifFalse)
Parameters
Type | Name | Description |
---|---|---|
Expression | test | Test expression. |
Expression | ifTrue | Positive branch. |
Expression | ifFalse | Negative branch. |
Returns
Type | Description |
---|---|
ConditionalExpression | Conditional expression. |
Type Parameters
Name | Description |
---|---|
R | The type of conditional expression. Default is |
Remarks
The equivalent code is a ? b : c
.
Const<T>(T)
Converts arbitrary value into constant expression.
Declaration
public static ConstantExpression Const<T>(this T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The constant value. |
Returns
Type | Description |
---|---|
ConstantExpression |
Type Parameters
Name | Description |
---|---|
T | The type of constant. |
Continue(LabelTarget)
Constructs loop continuation statement.
Declaration
public static GotoExpression Continue(this LabelTarget label)
Parameters
Type | Name | Description |
---|---|---|
LabelTarget | label | The label indicating loop start. |
Returns
Type | Description |
---|---|
GotoExpression | Continue statement. |
Convert(Expression, Type)
Constructs type conversion expression.
Declaration
public static UnaryExpression Convert(this Expression expression, Type targetType)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression to be converted. |
Type | targetType | The target type. |
Returns
Type | Description |
---|---|
UnaryExpression | The type conversion expression. |
Remarks
The equivalent code is (T)a
.
Convert<T>(Expression)
Constructs type conversion expression.
Declaration
public static UnaryExpression Convert<T>(this Expression expression)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression to be converted. |
Returns
Type | Description |
---|---|
UnaryExpression | The type conversion expression. |
Type Parameters
Name | Description |
---|---|
T | The target type. |
Remarks
The equivalent code is (T)a
.
Count(Expression)
Constructs expression representing count of items in the collection or string.
Declaration
public static MemberExpression Count(this Expression collection)
Parameters
Type | Name | Description |
---|---|---|
Expression | collection | The expression representing collection. |
Returns
Type | Description |
---|---|
MemberExpression | The expression providing access to the appropriate property indicating the number of items in the collection. |
Remarks
The input expression must be of type
Default(Type)
Constructs type default value supplier.
Declaration
public static DefaultExpression Default(this Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The target type. |
Returns
Type | Description |
---|---|
DefaultExpression | The type default value expression. |
Remarks
The equivalent code is default(T)
.
Divide(Expression, Expression)
Constructs binary arithmetic division expression.
Declaration
public static BinaryExpression Divide(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The left operand. |
Expression | right | The right operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a / b
ElementAt(Expression, Expression[])
Constructs array element access expression.
Declaration
public static IndexExpression ElementAt(this Expression array, params Expression[] indexes)
Parameters
Type | Name | Description |
---|---|---|
Expression | array | The array expression. |
Expression[] | indexes | Array element indicies. |
Returns
Type | Description |
---|---|
IndexExpression | Array element access expression. |
Remarks
The equivalent code is a.b[i]
.
Equal(Expression, Expression)
Constructs equality comparison.
Declaration
public static BinaryExpression Equal(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The left operand. |
Expression | right | The right operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a == b
Field(Expression, FieldInfo)
Constructs instance field access expression.
Declaration
public static MemberExpression Field(this Expression instance, FieldInfo field)
Parameters
Type | Name | Description |
---|---|---|
Expression | instance |
|
FieldInfo | field | Field metadata. |
Returns
Type | Description |
---|---|
MemberExpression | Field access expression. |
Remarks
The equivalent code is a.b
.
Field(Expression, String)
Constructs instance field access expression.
Declaration
public static MemberExpression Field(this Expression instance, string fieldName)
Parameters
Type | Name | Description |
---|---|---|
Expression | instance |
|
String | fieldName | The name of the instance field. |
Returns
Type | Description |
---|---|
MemberExpression | Field access expression. |
Remarks
The equivalent code is a.b
.
Finally(Expression, Expression)
Constructs a try
block with a finally
block without catch
block.
Declaration
public static TryExpression Finally(this Expression try, Expression finally)
Parameters
Type | Name | Description |
---|---|---|
Expression | try |
|
Expression | finally |
|
Returns
Type | Description |
---|---|
TryExpression | Try-finally statement. |
Remarks
The equivalent code is try { } finally { }
.
For(Expression, ForExpression.LoopBuilder.Condition, ForExpression.LoopBuilder.Iteration, ForExpression.LoopBuilder.Statement)
Creates for
loop expression.
Declaration
public static ForExpression For(this Expression initialization, ForExpression.LoopBuilder.Condition condition, ForExpression.LoopBuilder.Iteration iteration, ForExpression.LoopBuilder.Statement body)
Parameters
Type | Name | Description |
---|---|---|
Expression | initialization | Loop variable initialization expression. |
ForExpression.LoopBuilder.Condition | condition | The condition of loop continuation. |
ForExpression.LoopBuilder.Iteration | iteration | The loop iteration statement. |
ForExpression.LoopBuilder.Statement | body | The loop body. |
Returns
Type | Description |
---|---|
ForExpression | The constructed loop. |
ForEach(Expression, ForEachExpression.Statement)
Creates foreach
loop expression.
Declaration
public static ForEachExpression ForEach(this Expression collection, ForEachExpression.Statement body)
Parameters
Type | Name | Description |
---|---|---|
Expression | collection | The collection to iterate through. |
ForEachExpression.Statement | body | A delegate that is used to construct the body of the loop. |
Returns
Type | Description |
---|---|
ForEachExpression | The constructed loop. |
Fragment<D>(Expression<D>, Expression[])
Extracts body of lambda expression.
Declaration
public static Expression Fragment<D>(Expression<D> lambda, params Expression[] arguments)
where D : MulticastDelegate
Parameters
Type | Name | Description |
---|---|---|
Expression<D> | lambda | The lambda expression. |
Expression[] | arguments | The arguments used to replace lambda parameters. |
Returns
Type | Description |
---|---|
Expression | The body of lambda expression. |
Type Parameters
Name | Description |
---|---|
D | The type of the delegate describing lambda call site. |
Goto(LabelTarget)
Constructs unconditional control transfer statement.
Declaration
public static GotoExpression Goto(this LabelTarget label)
Parameters
Type | Name | Description |
---|---|---|
LabelTarget | label | The declared label. |
Returns
Type | Description |
---|---|
GotoExpression | Unconditional control transfer statement. |
Remarks
The equivalent code is goto label
.
Goto(LabelTarget, Expression)
Constructs unconditional control transfer expression.
Declaration
public static GotoExpression Goto(this LabelTarget label, Expression value)
Parameters
Type | Name | Description |
---|---|---|
LabelTarget | label | The declared label. |
Expression | value |
Returns
Type | Description |
---|---|
GotoExpression | Unconditional control transfer expression. |
GreaterThan(Expression, Expression)
Constructs "greater than" numeric comparison.
Declaration
public static BinaryExpression GreaterThan(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The left operand. |
Expression | right | The right operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a > b
GreaterThanOrEqual(Expression, Expression)
Constructs "greater than or equal" numeric comparison.
Declaration
public static BinaryExpression GreaterThanOrEqual(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The left operand. |
Expression | right | The right operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a >= b
IfNotNull(Expression, Func<ParameterExpression, Expression>)
Creates a new safe navigation expression.
Declaration
public static NullSafetyExpression IfNotNull(this Expression target, Func<ParameterExpression, Expression> body)
Parameters
Type | Name | Description |
---|---|---|
Expression | target | The expression that is guarded by null check. |
Func<ParameterExpression, Expression> | body | The body to be executed if |
Returns
Type | Description |
---|---|
NullSafetyExpression | The expression representing safe navigation. |
InstanceOf(Expression, Type)
Constructs type check expression.
Declaration
public static TypeBinaryExpression InstanceOf(this Expression expression, Type type)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression to test. |
Type | type | The target type. |
Returns
Type | Description |
---|---|
TypeBinaryExpression | The type test expression. |
Remarks
The equivalent code is a is T
.
InstanceOf<T>(Expression)
Constructs type check expression.
Declaration
public static TypeBinaryExpression InstanceOf<T>(this Expression expression)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression to test. |
Returns
Type | Description |
---|---|
TypeBinaryExpression | The type test expression. |
Type Parameters
Name | Description |
---|---|
T | The target type. |
Remarks
The equivalent code is a is T
.
Invoke(Expression, Expression[])
Constructs delegate invocation expression.
Declaration
public static InvocationExpression Invoke(this Expression delegate, params Expression[] arguments)
Parameters
Type | Name | Description |
---|---|---|
Expression | delegate | The expression representing delegate. |
Expression[] | arguments | Invocation arguments. |
Returns
Type | Description |
---|---|
InvocationExpression | Invocation expression. |
Remarks
The equivalent code is delegate.Invoke(a, b,...)
.
IsNotNull(Expression)
Constructs null check.
Declaration
public static Expression IsNotNull(this Expression operand)
Parameters
Type | Name | Description |
---|---|---|
Expression | operand | The operand. |
Returns
Type | Description |
---|---|
Expression | null check operation. |
Remarks
The equivalent code is !(a is null)
IsNull(Expression)
Constructs null check.
Declaration
public static Expression IsNull(this Expression operand)
Parameters
Type | Name | Description |
---|---|---|
Expression | operand | The operand. |
Returns
Type | Description |
---|---|
Expression | null check operation. |
Remarks
The equivalent code is a is null
LandingSite(LabelTarget)
Constructs label landing site.
Declaration
public static LabelExpression LandingSite(this LabelTarget label)
Parameters
Type | Name | Description |
---|---|---|
LabelTarget | label | The label reference. |
Returns
Type | Description |
---|---|
LabelExpression | The label landing site. |
Remarks
The equivalent code is label:
.
LandingSite(LabelTarget, Expression)
Constructs label landing site with the default value.
Declaration
public static LabelExpression LandingSite(this LabelTarget label, Expression default)
Parameters
Type | Name | Description |
---|---|---|
LabelTarget | label | The label reference. |
Expression | default | The default value associated with the label. |
Returns
Type | Description |
---|---|
LabelExpression | The label landing site. |
LeftShift(Expression, Expression)
Constructs bitwise left-shift expression.
Declaration
public static BinaryExpression LeftShift(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The left operand. |
Expression | right | The right operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a << b
in Visual Basic.
LessThan(Expression, Expression)
Constructs "less than" numeric comparison.
Declaration
public static BinaryExpression LessThan(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The left operand. |
Expression | right | The right operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a < b
LessThanOrEqual(Expression, Expression)
Constructs "less than or equal" numeric comparison.
Declaration
public static BinaryExpression LessThanOrEqual(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The left operand. |
Expression | right | The right operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a <= b
Lock(Expression, LockExpression.Statement)
Creates a new synchronized block of code.
Declaration
public static LockExpression Lock(this Expression syncRoot, LockExpression.Statement body)
Parameters
Type | Name | Description |
---|---|---|
Expression | syncRoot | The monitor object. |
LockExpression.Statement | body | The delegate used to construct synchronized block of code. |
Returns
Type | Description |
---|---|
LockExpression | The synchronized block of code. |
Loop(Expression)
Constructs loop statement.
Declaration
public static LoopExpression Loop(this Expression body)
Parameters
Type | Name | Description |
---|---|---|
Expression | body | The loop body. |
Returns
Type | Description |
---|---|
LoopExpression | Loop statement. |
Loop(Expression, LabelTarget)
Constructs loop statement.
Declaration
public static LoopExpression Loop(this Expression body, LabelTarget break)
Parameters
Type | Name | Description |
---|---|---|
Expression | body | The loop body. |
LabelTarget | break | Optional loop break label which will installed automatically. |
Returns
Type | Description |
---|---|
LoopExpression | Loop statement. |
Loop(Expression, LabelTarget, LabelTarget)
Constructs loop statement.
Declaration
public static LoopExpression Loop(this Expression body, LabelTarget break, LabelTarget continue)
Parameters
Type | Name | Description |
---|---|---|
Expression | body | The loop body. |
LabelTarget | break | Optional loop break label which will installed automatically. |
LabelTarget | continue | Optional loop continuation which will be installed automatically. |
Returns
Type | Description |
---|---|
LoopExpression | Loop statement. |
Modulo(Expression, Expression)
Constructs arithmetic remainder expression.
Declaration
public static BinaryExpression Modulo(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The left operand. |
Expression | right | The right operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a % b
Multiply(Expression, Expression)
Constructs binary arithmetic multiplication expression.
Declaration
public static BinaryExpression Multiply(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The left operand. |
Expression | right | The right operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a * b
Negate(Expression)
Constructs negate expression.
Declaration
public static UnaryExpression Negate(this Expression expression)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The operand. |
Returns
Type | Description |
---|---|
UnaryExpression | Unary expression. |
Remarks
The equivalent code is -a
New(Expression, Expression[])
Constructs type instantiation expression.
Declaration
public static MethodCallExpression New(this Expression type, params Expression[] args)
Parameters
Type | Name | Description |
---|---|---|
Expression | type | The expression representing the type to be instantiated. |
Expression[] | args | The list of arguments to be passed into constructor. |
Returns
Type | Description |
---|---|
MethodCallExpression | Instantiation expression. |
Remarks
The equivalent code is new T()
.
New(Type, Expression[])
Constructs type instantiation expression.
Declaration
public static NewExpression New(this Type type, params Expression[] args)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type to be instantiated. |
Expression[] | args | The list of arguments to be passed into constructor. |
Returns
Type | Description |
---|---|
NewExpression | Instantiation expression. |
Remarks
The equivalent code is new T()
.
Not(Expression)
Constructs logical NOT expression.
Declaration
public static UnaryExpression Not(this Expression expression)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The operand. |
Returns
Type | Description |
---|---|
UnaryExpression | Unary expression. |
Remarks
The equivalent code is !a
NotEqual(Expression, Expression)
Constructs inequality comparison.
Declaration
public static BinaryExpression NotEqual(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The left operand. |
Expression | right | The right operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a != b
OnesComplement(Expression)
Constructs ones complement.
Declaration
public static UnaryExpression OnesComplement(this Expression expression)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The operand. |
Returns
Type | Description |
---|---|
UnaryExpression | Unary expression. |
Remarks
The equivalent code is ~a
Or(Expression, Expression)
Constructs binary logical OR expression.
Declaration
public static BinaryExpression Or(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The left operand. |
Expression | right | The right operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a | b
OrElse(Expression, Expression)
Constructs binary expression that represents a conditional OR operation that evaluates the second operand only if the first operand evaluates to false.
Declaration
public static BinaryExpression OrElse(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The first operand. |
Expression | right | The second operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a || b
.
PostDecrementAssign(IndexExpression)
Constructs an expression that represents the assignment of given expression followed by a subsequent decrement by 1 of the original expression.
Declaration
public static UnaryExpression PostDecrementAssign(this IndexExpression operand)
Parameters
Type | Name | Description |
---|---|---|
IndexExpression | operand | The operand. |
Returns
Type | Description |
---|---|
UnaryExpression | Unary expression. |
Remarks
The equivalent code is a.b[i]--
.
PostDecrementAssign(MemberExpression)
Constructs an expression that represents the assignment of given expression followed by a subsequent decrement by 1 of the original expression.
Declaration
public static UnaryExpression PostDecrementAssign(this MemberExpression operand)
Parameters
Type | Name | Description |
---|---|---|
MemberExpression | operand | The operand. |
Returns
Type | Description |
---|---|
UnaryExpression | Unary expression. |
Remarks
The equivalent code is a.b--
.
PostDecrementAssign(ParameterExpression)
Constructs an expression that represents the assignment of given expression followed by a subsequent decrement by 1 of the original expression.
Declaration
public static UnaryExpression PostDecrementAssign(this ParameterExpression operand)
Parameters
Type | Name | Description |
---|---|---|
ParameterExpression | operand | The operand. |
Returns
Type | Description |
---|---|
UnaryExpression | Unary expression. |
Remarks
The equivalent code is i--
.
PostIncrementAssign(IndexExpression)
Constructs an expression that represents the assignment of given expression followed by a subsequent increment by 1 of the original expression.
Declaration
public static UnaryExpression PostIncrementAssign(this IndexExpression operand)
Parameters
Type | Name | Description |
---|---|---|
IndexExpression | operand | The operand. |
Returns
Type | Description |
---|---|
UnaryExpression | Unary expression. |
Remarks
The equivalent code is a.b[i]++
.
PostIncrementAssign(MemberExpression)
Constructs an expression that represents the assignment of given expression followed by a subsequent increment by 1 of the original expression.
Declaration
public static UnaryExpression PostIncrementAssign(this MemberExpression operand)
Parameters
Type | Name | Description |
---|---|---|
MemberExpression | operand | The operand. |
Returns
Type | Description |
---|---|
UnaryExpression | Unary expression. |
Remarks
The equivalent code is a.b++
.
PostIncrementAssign(ParameterExpression)
Constructs an expression that represents the assignment of given expression followed by a subsequent increment by 1 of the original expression.
Declaration
public static UnaryExpression PostIncrementAssign(this ParameterExpression operand)
Parameters
Type | Name | Description |
---|---|---|
ParameterExpression | operand | The operand. |
Returns
Type | Description |
---|---|
UnaryExpression | Unary expression. |
Remarks
The equivalent code is i++
.
Power(Expression, Expression)
Constructs raising a number to a power expression.
Declaration
public static BinaryExpression Power(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The left operand. |
Expression | right | The right operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a ^ b
in Visual Basic.
PreDecrementAssign(IndexExpression)
Constructs an expression that decrements given expression by 1 and assigns the result back to the expression.
Declaration
public static UnaryExpression PreDecrementAssign(this IndexExpression operand)
Parameters
Type | Name | Description |
---|---|---|
IndexExpression | operand | The operand. |
Returns
Type | Description |
---|---|
UnaryExpression | Unary expression. |
Remarks
The equivalent code is --a.b[i]
.
PreDecrementAssign(MemberExpression)
Constructs an expression that decrements given expression by 1 and assigns the result back to the expression.
Declaration
public static UnaryExpression PreDecrementAssign(this MemberExpression operand)
Parameters
Type | Name | Description |
---|---|---|
MemberExpression | operand | The operand. |
Returns
Type | Description |
---|---|
UnaryExpression | Unary expression. |
Remarks
The equivalent code is --a.b
.
PreDecrementAssign(ParameterExpression)
Constructs an expression that decrements given expression by 1 and assigns the result back to the expression.
Declaration
public static UnaryExpression PreDecrementAssign(this ParameterExpression operand)
Parameters
Type | Name | Description |
---|---|---|
ParameterExpression | operand | The operand. |
Returns
Type | Description |
---|---|
UnaryExpression | Unary expression. |
Remarks
The equivalent code is --i
.
PreIncrementAssign(IndexExpression)
Constructs an expression that increments given expression by 1 and assigns the result back to the expression.
Declaration
public static UnaryExpression PreIncrementAssign(this IndexExpression operand)
Parameters
Type | Name | Description |
---|---|---|
IndexExpression | operand | The operand. |
Returns
Type | Description |
---|---|
UnaryExpression | Unary expression. |
Remarks
The equivalent code is ++a.b[i]
.
PreIncrementAssign(MemberExpression)
Constructs an expression that increments given expression by 1 and assigns the result back to the expression.
Declaration
public static UnaryExpression PreIncrementAssign(this MemberExpression operand)
Parameters
Type | Name | Description |
---|---|---|
MemberExpression | operand | The operand. |
Returns
Type | Description |
---|---|
UnaryExpression | Unary expression. |
Remarks
The equivalent code is ++a.b
.
PreIncrementAssign(ParameterExpression)
Constructs an expression that increments given expression by 1 and assigns the result back to the expression.
Declaration
public static UnaryExpression PreIncrementAssign(this ParameterExpression operand)
Parameters
Type | Name | Description |
---|---|---|
ParameterExpression | operand | The operand. |
Returns
Type | Description |
---|---|
UnaryExpression | Unary expression. |
Remarks
The equivalent code is ++i
.
Property(Expression, PropertyInfo, Expression[])
Constructs instance property or indexer access expression.
Declaration
public static Expression Property(this Expression instance, PropertyInfo property, params Expression[] indicies)
Parameters
Type | Name | Description |
---|---|---|
Expression | instance |
|
PropertyInfo | property | Property metadata. |
Expression[] | indicies | Indexer indicies. |
Returns
Type | Description |
---|---|
Expression | Property access expression. |
Remarks
The equivalent code is a.b
or a.b[i]
.
Property(Expression, String, Expression[])
Constructs instance property or indexer access expression.
Declaration
public static Expression Property(this Expression instance, string propertyName, params Expression[] indicies)
Parameters
Type | Name | Description |
---|---|---|
Expression | instance |
|
String | propertyName | The name of the instance property or indexer. |
Expression[] | indicies | Indexer indicies. |
Returns
Type | Description |
---|---|
Expression | Property access expression. |
Remarks
The equivalent code is a.b
or a.b[i]
.
Property(Expression, Type, String, Expression[])
Constructs instance property or indexer access expression declared in the given interface or base type.
Declaration
public static Expression Property(this Expression instance, Type interfaceType, string propertyName, params Expression[] indicies)
Parameters
Type | Name | Description |
---|---|---|
Expression | instance |
|
Type | interfaceType | The interface or base class declaring property. |
String | propertyName | The name of the instance property or indexer. |
Expression[] | indicies | Indexer indicies. |
Returns
Type | Description |
---|---|
Expression | Property access expression. |
Remarks
The equivalent code is a.b
or a.b[i]
.
RefAnyVal(ParameterExpression, Type)
Creates a new expression that is equal to refanyval
IL instruction.
Declaration
public static RefAnyValExpression RefAnyVal(this ParameterExpression typedRef, Type referenceType)
Parameters
Type | Name | Description |
---|---|---|
ParameterExpression | typedRef | The variable of type |
Type | referenceType | The type of the managed reference. |
Returns
Type | Description |
---|---|
RefAnyValExpression | The expression representing statically typed referenced. |
RefAnyVal<T>(ParameterExpression)
Creates a new expression that is equal to refanyval
IL instruction.
Declaration
public static RefAnyValExpression RefAnyVal<T>(this ParameterExpression typedRef)
Parameters
Type | Name | Description |
---|---|---|
ParameterExpression | typedRef | The variable of type |
Returns
Type | Description |
---|---|
RefAnyValExpression | The expression representing statically typed referenced. |
Type Parameters
Name | Description |
---|---|
T | The type of the managed reference. |
Return(LabelTarget)
Constructs return
statement.
Declaration
public static GotoExpression Return(this LabelTarget label)
Parameters
Type | Name | Description |
---|---|---|
LabelTarget | label | The label representing function exit. |
Returns
Type | Description |
---|---|
GotoExpression | Return statement. |
Remarks
The equivalent code is return
.
Return(LabelTarget, Expression)
Constructs return
statement with given value.
Declaration
public static GotoExpression Return(this LabelTarget label, Expression value)
Parameters
Type | Name | Description |
---|---|---|
LabelTarget | label | The label representing function exit. |
Expression | value | The value to be returned from function. |
Returns
Type | Description |
---|---|
GotoExpression | Return statement. |
Remarks
The equivalent code is return a
.
RightShift(Expression, Expression)
Constructs bitwise right-shift expression.
Declaration
public static BinaryExpression RightShift(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The left operand. |
Expression | right | The right operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a >> b
in Visual Basic.
Subtract(Expression, Expression)
Constructs binary arithmetic subtraction expression.
Declaration
public static BinaryExpression Subtract(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The left operand. |
Expression | right | The right operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a - b
Throw(Expression, Type)
Constructs throw
expression.
Declaration
public static UnaryExpression Throw(this Expression exception, Type type = null)
Parameters
Type | Name | Description |
---|---|---|
Expression | exception | An exception to be thrown. |
Type | type | The type of expression. Default is |
Returns
Type | Description |
---|---|
UnaryExpression |
|
Remarks
The equivalent code is throw e
.
TryConvert(Expression, Type)
Constructs an expression that represents an explicit reference or boxing conversion where null is supplied if the conversion fails.
Declaration
public static UnaryExpression TryConvert(this Expression expression, Type type)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression to convert. |
Type | type | The target type. |
Returns
Type | Description |
---|---|
UnaryExpression | Type conversion expression. |
Remarks
The equivalent code is a as T
.
TryConvert<T>(Expression)
Constructs an expression that represents an explicit reference or boxing conversion where null is supplied if the conversion fails.
Declaration
public static UnaryExpression TryConvert<T>(this Expression expression)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The expression to convert. |
Returns
Type | Description |
---|---|
UnaryExpression | Type conversion expression. |
Type Parameters
Name | Description |
---|---|
T | The target type. |
Remarks
The equivalent code is a as T
.
UnaryPlus(Expression)
Constructs unary plus expression.
Declaration
public static UnaryExpression UnaryPlus(this Expression expression)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The operand. |
Returns
Type | Description |
---|---|
UnaryExpression | Unary expression. |
Remarks
The equivalent code is +a
Unbox(Expression, Type)
Constructs explicit unboxing.
Declaration
public static UnaryExpression Unbox(this Expression expression, Type type)
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The operand. |
Type | type | The target value type. |
Returns
Type | Description |
---|---|
UnaryExpression | Unboxing expression. |
Remarks
The equivalent code is (T)b
.
Unbox<T>(Expression)
Constructs explicit unboxing.
Declaration
public static UnaryExpression Unbox<T>(this Expression expression)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Expression | expression | The operand. |
Returns
Type | Description |
---|---|
UnaryExpression | Unboxing expression. |
Type Parameters
Name | Description |
---|---|
T | The target value type. |
Remarks
The equivalent code is (T)b
.
Until(Expression, WhileExpression.Statement)
Creates do{ }while()
loop expression.
Declaration
public static WhileExpression Until(this Expression condition, WhileExpression.Statement body)
Parameters
Type | Name | Description |
---|---|---|
Expression | condition | The loop condition. |
WhileExpression.Statement | body | The delegate that is used to construct loop body. |
Returns
Type | Description |
---|---|
WhileExpression | The constructed loop expression. |
Remarks
The equivalent code is do { } while(condition)
.
See Also
| Improve this Doc View SourceUsing(Expression, UsingExpression.Statement)
Creates block of code associated with disposable resource.
Declaration
public static UsingExpression Using(this Expression resource, UsingExpression.Statement body)
Parameters
Type | Name | Description |
---|---|---|
Expression | resource | The disposable resource. |
UsingExpression.Statement | body | The delegate used to construct the block of code. |
Returns
Type | Description |
---|---|
UsingExpression | The constructed expression. |
While(Expression, WhileExpression.Statement)
Creates while
loop expression.
Declaration
public static WhileExpression While(this Expression condition, WhileExpression.Statement body)
Parameters
Type | Name | Description |
---|---|---|
Expression | condition | The loop condition. |
WhileExpression.Statement | body | The delegate that is used to construct loop body. |
Returns
Type | Description |
---|---|
WhileExpression | The constructed loop expression. |
Remarks
The equivalent code is while(condition) { }
See Also
| Improve this Doc View SourceWith(Expression, WithExpression.Statement)
Creates a new instance of WithExpression.
Declaration
public static WithExpression With(this Expression obj, WithExpression.Statement body)
Parameters
Type | Name | Description |
---|---|---|
Expression | obj | The object to be referred inside of the body. |
WithExpression.Statement | body | The body of the expression. |
Returns
Type | Description |
---|---|
WithExpression | The constructed expression. |
See Also
| Improve this Doc View SourceXor(Expression, Expression)
Constructs binary logical exclusive OR expression.
Declaration
public static BinaryExpression Xor(this Expression left, Expression right)
Parameters
Type | Name | Description |
---|---|---|
Expression | left | The left operand. |
Expression | right | The right operand. |
Returns
Type | Description |
---|---|
BinaryExpression | Binary expression. |
Remarks
The equivalent code is a ^ b