Exemplo n.º 1
0
        private MemberAssignment BindProperty(PropertyInfo @prop, Expression exp)
        {
            var targetType = @prop.PropertyType;

            if (PriorityManager.IsValueType(targetType))
            {
                var targetLevel = PriorityManager.GetNumericLevel(targetType);
                var sourceLevel = PriorityManager.GetNumericLevel(exp.Type);
                if (targetLevel > sourceLevel ||
                    (targetLevel == sourceLevel && targetType.IsNullable()))
                {
                    exp = Expression.Convert(exp, targetType);
                }
            }
            return(Expression.Bind(@prop, exp));
        }
Exemplo n.º 2
0
        private void NumericExpressionOperator(ref ReadResult left, ref ReadResult right, Func <Expression, Expression, BinaryExpression> predicate)
        {
            if (left.Expression.Type != right.Expression.Type)
            {
                int leftLevel  = PriorityManager.GetNumericLevel(left.Expression.Type);
                int rightLevel = PriorityManager.GetNumericLevel(right.Expression.Type);

                if (leftLevel > rightLevel)
                {
                    right.Expression = Expression.Convert(right.Expression, left.Expression.Type);
                }
                else
                {
                    left.Expression = Expression.Convert(left.Expression, right.Expression.Type);
                }
            }

            left.Expression   = predicate(left.Expression, right.Expression);
            left.IsClosedWrap = left.IsClosedWrap || right.IsClosedWrap;
        }