public void Can_embed_normal_Expression_into_ExpressionInfo_eg_as_Constructor_argument() { var func = ExpressionCompiler.TryCompile <Func <P> >( ExpressionInfo.Lambda( ExpressionInfo.New(_ctorOfP, Expression.New(_ctorOfB)))); Assert.IsInstanceOf <P>(func()); }
public void Can_compile_lambda_without_coverting_to_expression() { var funcExpr = ExpressionInfo.Lambda( ExpressionInfo.New(typeof(X).GetTypeInfo().GetConstructors()[0], ExpressionInfo.New(typeof(Y).GetTypeInfo().GetConstructors()[0]))); var func = ExpressionCompiler.TryCompile <Func <X> >(funcExpr); Assert.IsNotNull(func); var x = func(); Assert.IsInstanceOf <X>(x); }
public static ExpressionInfo <Func <object[], object> > CreateComplexExpressionInfo() { var stateParamExpr = Expression.Parameter(typeof(object[])); var expr = ExpressionInfo.Lambda <Func <object[], object> >( ExpressionInfo.MemberInit( ExpressionInfo.New(_ctorOfA, ExpressionInfo.New(_ctorOfB), ExpressionInfo.Convert( ExpressionInfo.ArrayIndex(stateParamExpr, ExpressionInfo.Constant(11)), typeof(string)), ExpressionInfo.NewArrayInit(typeof(ID[]), ExpressionInfo.New(_ctorOfD1), ExpressionInfo.New(_ctorOfD2))), ExpressionInfo.Bind(_propAProp, ExpressionInfo.New(_ctorOfP, ExpressionInfo.New(_ctorOfB))), ExpressionInfo.Bind(_fieldABop, ExpressionInfo.New(_ctorOfB))), stateParamExpr); return(expr); }
public object CreateExpressionInfo_and_FastCompile() { var expr = ExpressionInfo.Lambda(ExpressionInfo.New(_xCtor, ExpressionInfo.New(_aCtor), ExpressionInfo.New(_bCtor))); return(expr.TryCompile <Func <object> >()); }
public object NewExpressionInfo() { return(ExpressionInfo.New(_xCtor, ExpressionInfo.Constant(_y))); }