public Expression FromAction <T1>(Expression <Func <T1> > p1, Expression <Action <T1> > expr)
 {
     return(ExpressionReplacer.
            Search(expr.Body).
            When(expr.Parameters[0], p1.Body).
            GetResult());
 }
예제 #2
0
        /// <summary>
        /// Perform two separate coercions over a single input (optionally performing separate complex type cocercion in the process),
        /// and then combine  the result of those two separate coercions into a single result.
        /// </summary>
        public Expression <Func <T1, T2> > MultiProject <T1, T2, T3, T4, T5, T6>(
            Expression <Func <T1, T3> > selector01,
            Expression <Func <T3, T5> > projector01,
            Expression <Func <T1, T4> > selector02,
            Expression <Func <T4, T6> > projector02,
            Expression <Func <T5, T6, T2> > combinator
            )
        {
            var param = Expression.Parameter(typeof(T1));

            var s1 = ExpressionReplacer.Search(selector01.Body).When(selector01.Parameters[0], replaceWith: param).GetResult();
            var p1 = ExpressionReplacer.Search(projector01.Body).When(projector01.Parameters[0], replaceWith: s1).GetResult();
            var s2 = ExpressionReplacer.Search(selector02.Body).When(selector02.Parameters[0], replaceWith: param).GetResult();
            var p2 = ExpressionReplacer.Search(projector02.Body).When(projector02.Parameters[0], replaceWith: s2).GetResult();

            var proj = ExpressionReplacer.Search(combinator.Body).
                       When(combinator.Parameters[0], replaceWith: p1).
                       When(combinator.Parameters[1], replaceWith: p2).
                       GetResult();

            return(Expression.Lambda <Func <T1, T2> >(
                       proj,
                       param
                       ));
        }
예제 #3
0
 public Expression <Func <T2> > FromFunc <T1, T2>(Expression <Func <T1> > p1, Expression <Func <T1, T2> > expr)
 {
     return(Expression.Lambda <Func <T2> >(
                ExpressionReplacer.
                Search(expr.Body).
                When(expr.Parameters[0], p1.Body).
                GetResult()
                ));
 }
 public Expression FromAction <T1, T2, T3>(Expression <Func <T1> > p1, Expression <Func <T2> > p2, Expression <Func <T3> > p3, Expression <Action <T1, T2, T3> > expr)
 {
     return(ExpressionReplacer.
            Search(expr.Body).
            When(expr.Parameters[0], p1.Body).
            When(expr.Parameters[1], p2.Body).
            When(expr.Parameters[2], p3.Body).
            GetResult());
 }
예제 #5
0
 public Expression <Func <T5> > FromFunc <T1, T2, T3, T4, T5>(Expression <Func <T1> > p1, Expression <Func <T2> > p2, Expression <Func <T3> > p3, Expression <Func <T4> > p4, Expression <Func <T1, T2, T3, T4, T5> > expr)
 {
     return(Expression.Lambda <Func <T5> >(
                ExpressionReplacer.
                Search(expr.Body).
                When(expr.Parameters[0], p1.Body).
                When(expr.Parameters[1], p2.Body).
                When(expr.Parameters[2], p3.Body).
                When(expr.Parameters[3], p4.Body).
                GetResult()
                ));
 }
 public Expression FromAction <T1, T2, T3, T4, T5, T6>(Expression <Func <T1> > p1, Expression <Func <T2> > p2, Expression <Func <T3> > p3, Expression <Func <T4> > p4, Expression <Func <T5> > p5, Expression <Func <T6> > p6, Expression <Action <T1, T2, T3, T4, T5, T6> > expr)
 {
     return(ExpressionReplacer.
            Search(expr.Body).
            When(expr.Parameters[0], p1.Body).
            When(expr.Parameters[1], p2.Body).
            When(expr.Parameters[2], p3.Body).
            When(expr.Parameters[3], p4.Body).
            When(expr.Parameters[4], p5.Body).
            When(expr.Parameters[5], p6.Body).
            GetResult());
 }
예제 #7
0
 public Expression <Func <T8> > FromFunc <T1, T2, T3, T4, T5, T6, T7, T8>(Expression <Func <T1> > p1, Expression <Func <T2> > p2, Expression <Func <T3> > p3, Expression <Func <T4> > p4, Expression <Func <T5> > p5, Expression <Func <T6> > p6, Expression <Func <T7> > p7, Expression <Func <T1, T2, T3, T4, T5, T6, T7, T8> > expr)
 {
     return(Expression.Lambda <Func <T8> >(
                ExpressionReplacer.
                Search(expr.Body).
                When(expr.Parameters[0], p1.Body).
                When(expr.Parameters[1], p2.Body).
                When(expr.Parameters[2], p3.Body).
                When(expr.Parameters[3], p4.Body).
                When(expr.Parameters[4], p5.Body).
                When(expr.Parameters[5], p6.Body).
                When(expr.Parameters[6], p7.Body).
                GetResult()
                ));
 }
 public Expression FromAction <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression <Func <T1> > p1, Expression <Func <T2> > p2, Expression <Func <T3> > p3, Expression <Func <T4> > p4, Expression <Func <T5> > p5, Expression <Func <T6> > p6, Expression <Func <T7> > p7, Expression <Func <T8> > p8, Expression <Func <T9> > p9, Expression <Func <T10> > p10, Expression <Action <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> > expr)
 {
     return(ExpressionReplacer.
            Search(expr.Body).
            When(expr.Parameters[0], p1.Body).
            When(expr.Parameters[1], p2.Body).
            When(expr.Parameters[2], p3.Body).
            When(expr.Parameters[3], p4.Body).
            When(expr.Parameters[4], p5.Body).
            When(expr.Parameters[5], p6.Body).
            When(expr.Parameters[6], p7.Body).
            When(expr.Parameters[7], p8.Body).
            When(expr.Parameters[8], p9.Body).
            When(expr.Parameters[9], p10.Body).
            GetResult());
 }
예제 #9
0
 public Expression <Func <T16> > FromFunc <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(Expression <Func <T1> > p1, Expression <Func <T2> > p2, Expression <Func <T3> > p3, Expression <Func <T4> > p4, Expression <Func <T5> > p5, Expression <Func <T6> > p6, Expression <Func <T7> > p7, Expression <Func <T8> > p8, Expression <Func <T9> > p9, Expression <Func <T10> > p10, Expression <Func <T11> > p11, Expression <Func <T12> > p12, Expression <Func <T13> > p13, Expression <Func <T14> > p14, Expression <Func <T15> > p15, Expression <Func <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> > expr)
 {
     return(Expression.Lambda <Func <T16> >(
                ExpressionReplacer.
                Search(expr.Body).
                When(expr.Parameters[0], p1.Body).
                When(expr.Parameters[1], p2.Body).
                When(expr.Parameters[2], p3.Body).
                When(expr.Parameters[3], p4.Body).
                When(expr.Parameters[4], p5.Body).
                When(expr.Parameters[5], p6.Body).
                When(expr.Parameters[6], p7.Body).
                When(expr.Parameters[7], p8.Body).
                When(expr.Parameters[8], p9.Body).
                When(expr.Parameters[9], p10.Body).
                When(expr.Parameters[10], p11.Body).
                When(expr.Parameters[11], p12.Body).
                When(expr.Parameters[12], p13.Body).
                When(expr.Parameters[13], p14.Body).
                When(expr.Parameters[14], p15.Body).
                GetResult()
                ));
 }