Exemplo n.º 1
0
        public Expression <Func <T, T, int> > CreateCompareMethod()
        {
            var x = Expression.Parameter(typeof(T));
            var y = Expression.Parameter(typeof(T));

            return(Expression.Lambda <Func <T, T, int> >(ComparerHelper.CreateComparerBody(null, null, x, y, CompareOptions, MembersOrder), x, y));
        }
Exemplo n.º 2
0
        public Expression <Func <IData, IData, int> > CreateCompareMethod()
        {
            var x = Expression.Parameter(typeof(IData));
            var y = Expression.Parameter(typeof(IData));

            List <Expression>          list       = new List <Expression>();
            List <ParameterExpression> parameters = new List <ParameterExpression>();

            var value1 = Expression.Variable(Type, "value1");

            parameters.Add(value1);
            list.Add(Expression.Assign(value1, Expression.Convert(x, DataType).Value()));

            var value2 = Expression.Variable(Type, "value2");

            parameters.Add(value2);
            list.Add(Expression.Assign(value2, Expression.Convert(y, DataType).Value()));

            return(Expression.Lambda <Func <IData, IData, int> >(ComparerHelper.CreateComparerBody(list, parameters, value1, value2, CompareOptions, MembersOrder), x, y));
        }