projects/wms-framework/src/lib/helpers/ExpressionTrees.ts
Expression class
Properties |
|
Readonly Body |
Type : CSharpExpression
|
Inherited from
LambdaExpression
|
Defined in
LambdaExpression:52
|
Readonly Name |
Type : string
|
Default value : null
|
Inherited from
LambdaExpression
|
Defined in
LambdaExpression:53
|
Readonly Parameters |
Type : ReadonlyCollection<ParameterExpression>
|
Inherited from
LambdaExpression
|
Defined in
LambdaExpression:54
|
Readonly NodeType |
Type : ExpressionType
|
Inherited from
CSharpExpression
|
Defined in
CSharpExpression:33
|
Readonly Type |
Type : RuntimeTypeInfo
|
Inherited from
CSharpExpression
|
Defined in
CSharpExpression:34
|
import { ReadonlyCollection } from '../baseframework/collections';
import {
MemberInfo,
PropertyInfo,
RuntimeTypeInfo,
} from '../baseframework/ReflectionSupport';
/**
* CSharpExpression class
*
* @export
* @class CSharpExpression
* @wType System.Linq.Expressions.Expression
* @wNetSupport
*/
export class CSharpExpression {
readonly NodeType: ExpressionType;
readonly Type: RuntimeTypeInfo;
constructor(nodeType: ExpressionType, type: RuntimeTypeInfo) {
this.NodeType = nodeType;
this.Type = type;
}
}
/**
* LambdaExpression class
*
* @export
* @class LambdaExpression
* @extends {CSharpExpression}
* @wType System.Linq.Expressions.LambdaExpression
* @wNetSupport
*/
export class LambdaExpression extends CSharpExpression {
readonly Body: CSharpExpression;
readonly Name: string = null;
readonly Parameters: ReadonlyCollection<ParameterExpression>;
constructor(
body: CSharpExpression,
name: string,
parameters: ReadonlyCollection<ParameterExpression>
) {
super(ExpressionType.Lambda, null);
this.Body = body;
this.Name = name;
this.Parameters = parameters;
}
}
/**
* ParameterExpression class
*
* @export
* @class ParameterExpression
* @extends {CSharpExpression}
* @wType System.Linq.Expressions.ParameterExpression
* @wNetSupport
*/
export class ParameterExpression extends CSharpExpression {
readonly Name: string = null;
constructor(type: RuntimeTypeInfo, name: string) {
super(ExpressionType.Parameter, type);
this.Name = name;
}
}
/**
* ConstantExpression class
*
* @export
* @class ConstantExpression
* @extends {CSharpExpression}
* @wType System.Linq.Expressions.ConstantExpression
* @wNetSupport
*/
export class ConstantExpression extends CSharpExpression {
/**
* Value of the constant expression.
*
* @type {*}
* @memberof ConstantExpression
* @wProperty Value
*/
readonly value: any = null;
constructor(value: any) {
super(ExpressionType.Constant, null);
this.value = value;
}
}
/**
* MemberExpression class
*
* @export
* @class MemberExpression
* @extends {CSharpExpression}
* @wType System.Linq.Expressions.MemberExpression
* @wNetSupport
*/
export class MemberExpression extends CSharpExpression {
readonly Expression: CSharpExpression;
readonly Member: MemberInfo;
constructor(expression: CSharpExpression, member: MemberInfo) {
super(ExpressionType.MemberAccess, null);
this.Expression = expression;
this.Member = member;
}
}
/**
* Expression class
*
* @export
* @class Expression
* @extends {LambdaExpression}
* @template T
* @wType System.Linq.Expressions.Expression`1
* @wNetSupport
*/
export class Expression<T> extends LambdaExpression {}
export class CSharpExpressionFactory {
public static Lambda<T>(
body: CSharpExpression,
...parameters: ParameterExpression[]
): Expression<T> {
return new Expression(body, null, new ReadonlyCollection(parameters));
}
public static Parameter(
type: RuntimeTypeInfo,
name: string
): ParameterExpression {
return new ParameterExpression(type, name);
}
public static Property(
expression: CSharpExpression,
propertyName: string
): MemberExpression {
const propertyInfo = new PropertyInfo(propertyName, null, null);
return new MemberExpression(expression, propertyInfo);
}
public static Constant(value: any): ConstantExpression {
return new ConstantExpression(value);
}
}
/**
* ExpressionType enum
*
* @export
* @enum {number}
* @wEnum System.Linq.Expressions.ExpressionType
* @wNetSupport
*/
export enum ExpressionType {
Add = 0,
AddChecked = 1,
And = 2,
AndAlso = 3,
ArrayLength = 4,
ArrayIndex = 5,
Call = 6,
Coalesce = 7,
Conditional = 8,
Constant = 9,
Convert = 10,
ConvertChecked = 11,
Divide = 12,
Equal = 13,
ExclusiveOr = 14,
GreaterThan = 15,
GreaterThanOrEqual = 16,
Invoke = 17,
Lambda = 18,
LeftShift = 19,
LessThan = 20,
LessThanOrEqual = 21,
ListInit = 22,
MemberAccess = 23,
MemberInit = 24,
Modulo = 25,
Multiply = 26,
MultiplyChecked = 27,
Negate = 28,
UnaryPlus = 29,
NegateChecked = 30,
New = 31,
NewArrayInit = 32,
NewArrayBounds = 33,
Not = 34,
NotEqual = 35,
Or = 36,
OrElse = 37,
Parameter = 38,
Power = 39,
Quote = 40,
RightShift = 41,
Subtract = 42,
SubtractChecked = 43,
TypeAs = 44,
TypeIs = 45,
Assign = 46,
Block = 47,
DebugInfo = 48,
Decrement = 49,
Dynamic = 50,
Default = 51,
Extension = 52,
Goto = 53,
Increment = 54,
Index = 55,
Label = 56,
RuntimeVariables = 57,
Loop = 58,
Switch = 59,
Throw = 60,
Try = 61,
Unbox = 62,
AddAssign = 63,
AndAssign = 64,
DivideAssign = 65,
ExclusiveOrAssign = 66,
LeftShiftAssign = 67,
ModuloAssign = 68,
MultiplyAssign = 69,
OrAssign = 70,
PowerAssign = 71,
RightShiftAssign = 72,
SubtractAssign = 73,
AddAssignChecked = 74,
MultiplyAssignChecked = 75,
SubtractAssignChecked = 76,
PreIncrementAssign = 77,
PreDecrementAssign = 78,
PostIncrementAssign = 79,
PostDecrementAssign = 80,
TypeEqual = 81,
OnesComplement = 82,
IsTrue = 83,
IsFalse = 84,
}