Combine() public static méthode

public static Combine ( Expression, outer, Expression, inner, bool inline ) : T3>>.Expression
outer Expression,
inner Expression,
inline bool
Résultat T3>>.Expression
Exemple #1
0
    static void Main()
    {
        var qry = from type in typeof(Expression).Assembly.GetTypes()
                  where type.IsClass && !type.IsAbstract &&
                  type.IsSubclassOf(typeof(Expression))
                  select type.FullName;
        Expression <Func <GrandParent, Parent> > myFirst  = gp => gp.Parent;
        Expression <Func <Parent, string> >      mySecond = p => p.Child.Name;

        Expression <Func <GrandParent, string> > outputWithInline    = myFirst.Combine(mySecond, false);
        Expression <Func <GrandParent, string> > outputWithoutInline = myFirst.Combine(mySecond, true);

        Expression <Func <GrandParent, string> > call =
            ExpressionUtils.Combine <GrandParent, Parent, string>(
                gp => gp.Parent, p => p.Method(p.Child.Name), true);

        unchecked
        {
            Expression <Func <double, double> > mathUnchecked =
                ExpressionUtils.Combine <double, double, double>(x => (x * x) + x, x => x - (x / x), true);
        }
        checked
        {
            Expression <Func <double, double> > mathChecked =
                ExpressionUtils.Combine <double, double, double>(x => x - (x * x), x => (x / x) + x, true);
        }
        Expression <Func <int, int> > bitwise =
            ExpressionUtils.Combine <int, int, int>(x => (x & 0x01) | 0x03, x => x ^ 0xFF, true);
        Expression <Func <int, bool> > logical =
            ExpressionUtils.Combine <int, bool, bool>(x => x == 123, x => x != false, true);
    }
    static void Main()
    {
        Expression <Func <GrandParent, Parent> > myFirst  = gp => gp.Parent;
        Expression <Func <Parent, string> >      mySecond = p => p.Child.Name;

        Expression <Func <GrandParent, string> > outputWithInline    = myFirst.Combine(mySecond, false);
        Expression <Func <GrandParent, string> > outputWithoutInline = myFirst.Combine(mySecond, true);

        Expression <Func <GrandParent, string> > call =
            ExpressionUtils.Combine <GrandParent, Parent, string>(
                gp => gp.Parent, p => p.Method(p.Child.Name), true);

        unchecked
        {
            Expression <Func <double, double> > mathUnchecked =
                ExpressionUtils.Combine <double, double, double>(x => (x * x) + x, x => x - (x / x), true);
        }
        checked
        {
            Expression <Func <double, double> > mathChecked =
                ExpressionUtils.Combine <double, double, double>(x => x - (x * x), x => (x / x) + x, true);
        }
        Expression <Func <int, int> > bitwise =
            ExpressionUtils.Combine <int, int, int>(x => (x & 0x01) | 0x03, x => x ^ 0xFF, true);
        Expression <Func <int, bool> > logical =
            ExpressionUtils.Combine <int, bool, bool>(x => x == 123, x => x != false, true);
        Expression <Func <int[][], int> > arrayAccess =
            ExpressionUtils.Combine <int[][], int[], int>(x => x[0], x => x[0], true);
        Expression <Func <string, bool> > isTest =
            ExpressionUtils.Combine <string, object, bool>(s => s, s => s is Regex, true);

        Expression <Func <List <int> > >   f      = () => new List <int>(new int[] { 1, 1, 1 }.Length);
        Expression <Func <string, Regex> > asTest =
            ExpressionUtils.Combine <string, object, Regex>(s => s, s => s as Regex, true);
        var initTest = ExpressionUtils.Combine <int, int[], List <int> >(i => new[] { i, i, i },
                                                                         arr => new List <int>(arr.Length), true);
        var anonAndListTest = ExpressionUtils.Combine <int, int, List <int> >(
            i => new { age = i }.age, i => new List <int> {
            i, i
        }, true);

        /*
         * var arrBoundsInit = ExpressionUtils.Combine<int, int[], int[]>(
         *  i => new int[i], arr => new int[arr[0]] , true);
         * var arrInit = ExpressionUtils.Combine<int, int, int[]>(
         *  i => i, i => new int[1] { i }, true);*/
    }