Beispiel #1
0
 public void MakeBinaryOperandsCompatible(Type leftType, Type rightType, ref Expression leftExpression, ref Expression rightExpression)
 {
     if (CanBeConverted(leftType, rightType))
     {
         leftExpression = VelocityExpressions.ConvertIfNeeded(leftExpression, rightType);
     }
     else if (CanBeConverted(rightType, leftType))
     {
         rightExpression = VelocityExpressions.ConvertIfNeeded(rightExpression, leftType);
     }
     else if (leftType == typeof(string) && (rightType == typeof(char) || rightType.IsEnum))
     {
         rightExpression = Expression.Call(rightExpression, MethodHelpers.ToStringMethodInfo);
     }
     else if (rightType == typeof(string) && (leftType == typeof(char) || leftType.IsEnum))
     {
         leftExpression = Expression.Call(leftExpression, MethodHelpers.ToStringMethodInfo);
     }
     else if (leftType != rightType && TypeHelper.IsInteger(leftType) && TypeHelper.IsInteger(rightType))
     {
         leftExpression  = BigIntegerHelper.ConvertToBigInteger(leftExpression);
         rightExpression = BigIntegerHelper.ConvertToBigInteger(rightExpression);
     }
 }