Ejemplo n.º 1
0
        internal override void Execute(RuleExecution execution)
        {
            Type expressionType          = execution.Validation.ExpressionInfo(this.assignStatement.Left).ExpressionType;
            Type operandType             = execution.Validation.ExpressionInfo(this.assignStatement.Right).ExpressionType;
            RuleExpressionResult result  = RuleExpressionWalker.Evaluate(execution, this.assignStatement.Left);
            RuleExpressionResult result2 = RuleExpressionWalker.Evaluate(execution, this.assignStatement.Right);

            result.Value = Executor.AdjustType(operandType, result2.Value, expressionType);
        }
Ejemplo n.º 2
0
        internal override RuleExpressionResult Evaluate(CodeExpression expression, RuleExecution execution)
        {
            CodeIndexerExpression      expression2 = (CodeIndexerExpression)expression;
            RulePropertyExpressionInfo info        = execution.Validation.ExpressionInfo(expression2) as RulePropertyExpressionInfo;

            if (info == null)
            {
                InvalidOperationException exception = new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Messages.ExpressionNotValidated, new object[0]));
                exception.Data["ErrorObject"] = expression2;
                throw exception;
            }
            PropertyInfo propertyInfo = info.PropertyInfo;
            object       targetObject = RuleExpressionWalker.Evaluate(execution, expression2.TargetObject).Value;

            if (targetObject == null)
            {
                RuleEvaluationException exception2 = new RuleEvaluationException(string.Format(CultureInfo.CurrentCulture, Messages.TargetEvaluatedNullIndexer, new object[0]));
                exception2.Data["ErrorObject"] = expression2;
                throw exception2;
            }
            int count = expression2.Indices.Count;

            ParameterInfo[] indexParameters  = propertyInfo.GetIndexParameters();
            object[]        indexerArguments = new object[indexParameters.Length];
            int             length           = indexParameters.Length;

            if (info.NeedsParamsExpansion)
            {
                length--;
            }
            int index = 0;

            while (index < length)
            {
                Type expressionType         = execution.Validation.ExpressionInfo(expression2.Indices[index]).ExpressionType;
                RuleExpressionResult result = RuleExpressionWalker.Evaluate(execution, expression2.Indices[index]);
                indexerArguments[index] = Executor.AdjustType(expressionType, result.Value, indexParameters[index].ParameterType);
                index++;
            }
            if (length < count)
            {
                ParameterInfo info3         = indexParameters[length];
                Type          parameterType = info3.ParameterType;
                Type          elementType   = parameterType.GetElementType();
                Array         array         = (Array)parameterType.InvokeMember(parameterType.Name, BindingFlags.CreateInstance, null, null, new object[] { count - index }, CultureInfo.CurrentCulture);
                while (index < count)
                {
                    Type operandType             = execution.Validation.ExpressionInfo(expression2.Indices[index]).ExpressionType;
                    RuleExpressionResult result2 = RuleExpressionWalker.Evaluate(execution, expression2.Indices[index]);
                    array.SetValue(Executor.AdjustType(operandType, result2.Value, elementType), (int)(index - length));
                    index++;
                }
                indexerArguments[length] = array;
            }
            return(new RulePropertyResult(propertyInfo, targetObject, indexerArguments));
        }
        internal override void Execute(RuleExecution execution)
        {
            Type leftType  = execution.Validation.ExpressionInfo(assignStatement.Left).ExpressionType;
            Type rightType = execution.Validation.ExpressionInfo(assignStatement.Right).ExpressionType;

            RuleExpressionResult leftResult  = RuleExpressionWalker.Evaluate(execution, assignStatement.Left);
            RuleExpressionResult rightResult = RuleExpressionWalker.Evaluate(execution, assignStatement.Right);

            leftResult.Value = Executor.AdjustType(rightType, rightResult.Value, leftType);
        }
Ejemplo n.º 4
0
        public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
        {
            if (parameters[0] == null)
            {
                return(Activator.CreateInstance(base.resultType));
            }
            object operandValue = base.actualMethod.Invoke(null, invokeAttr, binder, parameters, culture);

            return(Executor.AdjustType(base.actualMethod.ReturnType, operandValue, base.resultType));
        }
        internal override RuleExpressionResult Evaluate(CodeExpression expression, RuleExecution execution)
        {
            object obj5;
            CodeBinaryOperatorExpression expression2 = (CodeBinaryOperatorExpression)expression;
            object operandValue = RuleExpressionWalker.Evaluate(execution, expression2.Left).Value;
            CodeBinaryOperatorType @operator = expression2.Operator;

            switch (@operator)
            {
            case CodeBinaryOperatorType.BooleanAnd:
                if ((bool)operandValue)
                {
                    return(new RuleLiteralResult(RuleExpressionWalker.Evaluate(execution, expression2.Right).Value));
                }
                return(new RuleLiteralResult(false));

            case CodeBinaryOperatorType.BooleanOr:
                if ((bool)operandValue)
                {
                    return(new RuleLiteralResult(true));
                }
                return(new RuleLiteralResult(RuleExpressionWalker.Evaluate(execution, expression2.Right).Value));
            }
            object obj6 = RuleExpressionWalker.Evaluate(execution, expression2.Right).Value;
            RuleBinaryExpressionInfo info = execution.Validation.ExpressionInfo(expression2) as RuleBinaryExpressionInfo;

            if (info == null)
            {
                InvalidOperationException exception = new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Messages.ExpressionNotValidated, new object[0]));
                exception.Data["ErrorObject"] = expression2;
                throw exception;
            }
            MethodInfo methodInfo = info.MethodInfo;

            if (methodInfo != null)
            {
                if (methodInfo == Literal.ObjectEquality)
                {
                    obj5 = operandValue == obj6;
                }
                else
                {
                    ParameterInfo[] parameters = methodInfo.GetParameters();
                    object[]        objArray   = new object[] { Executor.AdjustType(info.LeftType, operandValue, parameters[0].ParameterType), Executor.AdjustType(info.RightType, obj6, parameters[1].ParameterType) };
                    obj5 = methodInfo.Invoke(null, objArray);
                }
            }
            else
            {
                obj5 = EvaluateBinaryOperation(expression2, info.LeftType, operandValue, @operator, info.RightType, obj6);
            }
            return(new RuleLiteralResult(obj5));
        }
        internal override RuleExpressionResult Evaluate(CodeExpression expression, RuleExecution execution)
        {
            CodeArrayIndexerExpression expression2 = (CodeArrayIndexerExpression)expression;
            object obj2 = RuleExpressionWalker.Evaluate(execution, expression2.TargetObject).Value;

            if (obj2 == null)
            {
                RuleEvaluationException exception = new RuleEvaluationException(string.Format(CultureInfo.CurrentCulture, Messages.TargetEvaluatedNullIndexer, new object[0]));
                exception.Data["ErrorObject"] = expression2;
                throw exception;
            }
            int count = expression2.Indices.Count;

            long[] indexerArguments = new long[count];
            for (int i = 0; i < count; i++)
            {
                Type   expressionType = execution.Validation.ExpressionInfo(expression2.Indices[i]).ExpressionType;
                object operandValue   = RuleExpressionWalker.Evaluate(execution, expression2.Indices[i]).Value;
                indexerArguments[i] = (long)Executor.AdjustType(expressionType, operandValue, typeof(long));
            }
            return(new RuleArrayElementResult((Array)obj2, indexerArguments));
        }
        public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
        {
            object[] destinationArray = new object[this.actualParameterLength];
            if (this.actualParameterLength > 1)
            {
                Array.Copy(parameters, 0, destinationArray, 1, this.actualParameterLength - 1);
            }
            if (obj == null)
            {
                destinationArray[0] = null;
            }
            else
            {
                destinationArray[0] = Executor.AdjustType(obj.GetType(), obj, this.assumedDeclaringType);
            }
            object obj2 = this.actualMethod.Invoke(null, invokeAttr, binder, destinationArray, culture);

            if (this.hasOutOrRefParameters)
            {
                Array.Copy(destinationArray, 1, parameters, 0, this.actualParameterLength - 1);
            }
            return(obj2);
        }
Ejemplo n.º 8
0
        internal override RuleExpressionResult Evaluate(CodeExpression expression, RuleExecution execution)
        {
            CodeArrayCreateExpression expression2 = (CodeArrayCreateExpression)expression;

            if (expression2.CreateType == null)
            {
                RuleEvaluationException exception = new RuleEvaluationException(Messages.NullTypeType);
                exception.Data["ErrorObject"] = expression2;
                throw exception;
            }
            RuleExpressionInfo info = execution.Validation.ExpressionInfo(expression2);

            if (expression2 == null)
            {
                InvalidOperationException exception2 = new InvalidOperationException(Messages.ExpressionNotValidated);
                exception2.Data["ErrorObject"] = expression2;
                throw exception2;
            }
            Type elementType = info.ExpressionType.GetElementType();
            int  length      = 0;

            if (expression2.SizeExpression != null)
            {
                Type expressionType         = execution.Validation.ExpressionInfo(expression2.SizeExpression).ExpressionType;
                RuleExpressionResult result = RuleExpressionWalker.Evaluate(execution, expression2.SizeExpression);
                if (expressionType == typeof(int))
                {
                    length = (int)result.Value;
                }
                else if (expressionType == typeof(long))
                {
                    length = (int)((long)result.Value);
                }
                else if (expressionType == typeof(uint))
                {
                    length = (int)((uint)result.Value);
                }
                else if (expressionType == typeof(ulong))
                {
                    length = (int)((ulong)result.Value);
                }
            }
            else if (expression2.Size != 0)
            {
                length = expression2.Size;
            }
            else
            {
                length = expression2.Initializers.Count;
            }
            Array literal = Array.CreateInstance(elementType, length);

            if (expression2.Initializers != null)
            {
                for (int i = 0; i < expression2.Initializers.Count; i++)
                {
                    CodeExpression       expression3 = expression2.Initializers[i];
                    Type                 operandType = execution.Validation.ExpressionInfo(expression3).ExpressionType;
                    RuleExpressionResult result2     = RuleExpressionWalker.Evaluate(execution, expression3);
                    literal.SetValue(Executor.AdjustType(operandType, result2.Value, elementType), i);
                }
            }
            return(new RuleLiteralResult(literal));
        }
Ejemplo n.º 9
0
        internal override RuleExpressionInfo Validate(CodeExpression expression, RuleValidation validation, bool isWritten)
        {
            CodeArrayCreateExpression newParent = (CodeArrayCreateExpression)expression;

            if (isWritten)
            {
                ValidationError item = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.CannotWriteToExpression, new object[] { typeof(CodeObjectCreateExpression).ToString() }), 0x17a);
                item.UserData["ErrorObject"] = newParent;
                validation.Errors.Add(item);
                return(null);
            }
            if (newParent.CreateType == null)
            {
                ValidationError error2 = new ValidationError(Messages.NullTypeType, 0x53d);
                error2.UserData["ErrorObject"] = newParent;
                validation.Errors.Add(error2);
                return(null);
            }
            Type lhsType = validation.ResolveType(newParent.CreateType);

            if (lhsType == null)
            {
                return(null);
            }
            if (lhsType.IsArray)
            {
                ValidationError error3 = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.ArrayTypeInvalid, new object[] { lhsType.Name }), 0x53d);
                error3.UserData["ErrorObject"] = newParent;
                validation.Errors.Add(error3);
                return(null);
            }
            try
            {
                if (!validation.PushParentExpression(newParent))
                {
                    return(null);
                }
                if (newParent.Size < 0)
                {
                    ValidationError error4 = new ValidationError(Messages.ArraySizeInvalid, 0x53d);
                    error4.UserData["ErrorObject"] = newParent;
                    validation.Errors.Add(error4);
                    return(null);
                }
                if (newParent.SizeExpression != null)
                {
                    RuleExpressionInfo info = RuleExpressionWalker.Validate(validation, newParent.SizeExpression, false);
                    if (info == null)
                    {
                        return(null);
                    }
                    if (((info.ExpressionType != typeof(int)) && (info.ExpressionType != typeof(uint))) && ((info.ExpressionType != typeof(long)) && (info.ExpressionType != typeof(ulong))))
                    {
                        ValidationError error5 = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.ArraySizeTypeInvalid, new object[] { info.ExpressionType.Name }), 0x53d);
                        error5.UserData["ErrorObject"] = newParent;
                        validation.Errors.Add(error5);
                        return(null);
                    }
                }
                bool flag = false;
                for (int i = 0; i < newParent.Initializers.Count; i++)
                {
                    CodeExpression expression3 = newParent.Initializers[i];
                    if (expression3 == null)
                    {
                        ValidationError error6 = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.MissingInitializer, new object[] { lhsType.Name }), 0x53d);
                        error6.UserData["ErrorObject"] = newParent;
                        validation.Errors.Add(error6);
                        return(null);
                    }
                    RuleExpressionInfo info2 = RuleExpressionWalker.Validate(validation, expression3, false);
                    if (info2 == null)
                    {
                        flag = true;
                    }
                    else
                    {
                        ValidationError error7;
                        if (!RuleValidation.StandardImplicitConversion(info2.ExpressionType, lhsType, expression3, out error7))
                        {
                            if (error7 != null)
                            {
                                error7.UserData["ErrorObject"] = newParent;
                                validation.Errors.Add(error7);
                            }
                            error7 = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.InitializerMismatch, new object[] { i, lhsType.Name }), 0x545);
                            error7.UserData["ErrorObject"] = newParent;
                            validation.Errors.Add(error7);
                            return(null);
                        }
                    }
                }
                if (flag)
                {
                    return(null);
                }
                double size = -1.0;
                if (newParent.SizeExpression != null)
                {
                    CodePrimitiveExpression sizeExpression = newParent.SizeExpression as CodePrimitiveExpression;
                    if ((sizeExpression != null) && (sizeExpression.Value != null))
                    {
                        size = (double)Executor.AdjustType(sizeExpression.Value.GetType(), sizeExpression.Value, typeof(double));
                    }
                    if (newParent.Size > 0)
                    {
                        ValidationError error8 = new ValidationError(Messages.ArraySizeBoth, 0x53d);
                        error8.UserData["ErrorObject"] = newParent;
                        validation.Errors.Add(error8);
                        return(null);
                    }
                }
                else if (newParent.Size > 0)
                {
                    size = newParent.Size;
                }
                if ((size >= 0.0) && (newParent.Initializers.Count > size))
                {
                    ValidationError error9 = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.InitializerCountMismatch, new object[] { newParent.Initializers.Count, size }), 0x545);
                    error9.UserData["ErrorObject"] = newParent;
                    validation.Errors.Add(error9);
                    return(null);
                }
            }
            finally
            {
                validation.PopParentExpression();
            }
            return(new RuleExpressionInfo(lhsType.MakeArrayType()));
        }
        internal override RuleExpressionResult Evaluate(CodeExpression expression, RuleExecution execution)
        {
            object obj2;
            CodeObjectCreateExpression expression2 = (CodeObjectCreateExpression)expression;

            if (expression2.CreateType == null)
            {
                RuleEvaluationException exception = new RuleEvaluationException(Messages.NullTypeType);
                exception.Data["ErrorObject"] = expression2;
                throw exception;
            }
            RuleExpressionInfo info = execution.Validation.ExpressionInfo(expression2);

            if (info == null)
            {
                InvalidOperationException exception2 = new InvalidOperationException(Messages.ExpressionNotValidated);
                exception2.Data["ErrorObject"] = expression2;
                throw exception2;
            }
            RuleConstructorExpressionInfo info2 = info as RuleConstructorExpressionInfo;

            if (info2 == null)
            {
                return(new RuleLiteralResult(Activator.CreateInstance(info.ExpressionType)));
            }
            ConstructorInfo constructorInfo = info2.ConstructorInfo;

            object[] parameters = null;
            RuleExpressionResult[] resultArray = null;
            if ((expression2.Parameters != null) && (expression2.Parameters.Count > 0))
            {
                int             count     = expression2.Parameters.Count;
                ParameterInfo[] infoArray = constructorInfo.GetParameters();
                parameters = new object[infoArray.Length];
                int length = infoArray.Length;
                if (info2.NeedsParamsExpansion)
                {
                    length--;
                }
                int index = 0;
                while (index < length)
                {
                    Type expressionType                 = execution.Validation.ExpressionInfo(expression2.Parameters[index]).ExpressionType;
                    RuleExpressionResult    result      = RuleExpressionWalker.Evaluate(execution, expression2.Parameters[index]);
                    CodeDirectionExpression expression3 = expression2.Parameters[index] as CodeDirectionExpression;
                    if ((expression3 != null) && ((expression3.Direction == FieldDirection.Ref) || (expression3.Direction == FieldDirection.Out)))
                    {
                        if (resultArray == null)
                        {
                            resultArray = new RuleExpressionResult[count];
                        }
                        resultArray[index] = result;
                    }
                    parameters[index] = Executor.AdjustType(expressionType, result.Value, infoArray[index].ParameterType);
                    index++;
                }
                if (length < count)
                {
                    ParameterInfo info4       = infoArray[length];
                    Type          elementType = info4.ParameterType.GetElementType();
                    Array         array       = Array.CreateInstance(elementType, (int)(count - index));
                    while (index < count)
                    {
                        Type operandType             = execution.Validation.ExpressionInfo(expression2.Parameters[index]).ExpressionType;
                        RuleExpressionResult result2 = RuleExpressionWalker.Evaluate(execution, expression2.Parameters[index]);
                        array.SetValue(Executor.AdjustType(operandType, result2.Value, elementType), (int)(index - length));
                        index++;
                    }
                    parameters[length] = array;
                }
            }
            try
            {
                obj2 = constructorInfo.Invoke(parameters);
            }
            catch (TargetInvocationException exception3)
            {
                if (exception3.InnerException == null)
                {
                    throw;
                }
                throw new TargetInvocationException(string.Format(CultureInfo.CurrentCulture, Messages.Error_ConstructorInvoke, new object[] { RuleDecompiler.DecompileType(info2.ExpressionType), exception3.InnerException.Message }), exception3.InnerException);
            }
            if (resultArray != null)
            {
                for (int i = 0; i < expression2.Parameters.Count; i++)
                {
                    if (resultArray[i] != null)
                    {
                        resultArray[i].Value = parameters[i];
                    }
                }
            }
            return(new RuleLiteralResult(obj2));
        }
Ejemplo n.º 11
0
        internal override RuleExpressionResult Evaluate(CodeExpression expression, RuleExecution execution)
        {
            object obj3;
            CodeMethodInvokeExpression expression2 = (CodeMethodInvokeExpression)expression;
            object obj2 = RuleExpressionWalker.Evaluate(execution, expression2.Method.TargetObject).Value;
            RuleMethodInvokeExpressionInfo info = execution.Validation.ExpressionInfo(expression2) as RuleMethodInvokeExpressionInfo;

            if (info == null)
            {
                InvalidOperationException exception = new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Messages.ExpressionNotValidated, new object[0]));
                exception.Data["ErrorObject"] = expression2;
                throw exception;
            }
            MethodInfo methodInfo = info.MethodInfo;

            if (!methodInfo.IsStatic && (obj2 == null))
            {
                RuleEvaluationException exception2 = new RuleEvaluationException(string.Format(CultureInfo.CurrentCulture, Messages.TargetEvaluatedNullMethod, new object[] { expression2.Method.MethodName }));
                exception2.Data["ErrorObject"] = expression2;
                throw exception2;
            }
            object[] parameters = null;
            RuleExpressionResult[] resultArray = null;
            if ((expression2.Parameters != null) && (expression2.Parameters.Count > 0))
            {
                int             count     = expression2.Parameters.Count;
                ParameterInfo[] infoArray = methodInfo.GetParameters();
                parameters = new object[infoArray.Length];
                int length = infoArray.Length;
                if (info.NeedsParamsExpansion)
                {
                    length--;
                }
                int index = 0;
                while (index < length)
                {
                    Type expressionType                 = execution.Validation.ExpressionInfo(expression2.Parameters[index]).ExpressionType;
                    RuleExpressionResult    result      = RuleExpressionWalker.Evaluate(execution, expression2.Parameters[index]);
                    CodeDirectionExpression expression3 = expression2.Parameters[index] as CodeDirectionExpression;
                    if ((expression3 != null) && ((expression3.Direction == FieldDirection.Ref) || (expression3.Direction == FieldDirection.Out)))
                    {
                        if (resultArray == null)
                        {
                            resultArray = new RuleExpressionResult[expression2.Parameters.Count];
                        }
                        resultArray[index] = result;
                        if (expression3.Direction != FieldDirection.Out)
                        {
                            parameters[index] = Executor.AdjustType(expressionType, result.Value, infoArray[index].ParameterType);
                        }
                    }
                    else
                    {
                        parameters[index] = Executor.AdjustType(expressionType, result.Value, infoArray[index].ParameterType);
                    }
                    index++;
                }
                if (length < count)
                {
                    ParameterInfo info3         = infoArray[length];
                    Type          parameterType = info3.ParameterType;
                    Type          elementType   = parameterType.GetElementType();
                    Array         array         = (Array)parameterType.InvokeMember(parameterType.Name, BindingFlags.CreateInstance, null, null, new object[] { count - index }, CultureInfo.CurrentCulture);
                    while (index < count)
                    {
                        Type operandType             = execution.Validation.ExpressionInfo(expression2.Parameters[index]).ExpressionType;
                        RuleExpressionResult result2 = RuleExpressionWalker.Evaluate(execution, expression2.Parameters[index]);
                        array.SetValue(Executor.AdjustType(operandType, result2.Value, elementType), (int)(index - length));
                        index++;
                    }
                    parameters[length] = array;
                }
            }
            try
            {
                obj3 = methodInfo.Invoke(obj2, parameters);
            }
            catch (TargetInvocationException exception3)
            {
                if (exception3.InnerException == null)
                {
                    throw;
                }
                throw new TargetInvocationException(string.Format(CultureInfo.CurrentCulture, Messages.Error_MethodInvoke, new object[] { RuleDecompiler.DecompileType(methodInfo.ReflectedType), methodInfo.Name, exception3.InnerException.Message }), exception3.InnerException);
            }
            if (resultArray != null)
            {
                for (int i = 0; i < expression2.Parameters.Count; i++)
                {
                    if (resultArray[i] != null)
                    {
                        resultArray[i].Value = parameters[i];
                    }
                }
            }
            return(new RuleLiteralResult(obj3));
        }
        public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
        {
            object            obj2;
            ArithmeticLiteral literal;
            ArithmeticLiteral literal2;
            Literal           literal3;
            Literal           literal4;

            if (this.lhsRootType == null)
            {
                this.lhsRootType = Enum.GetUnderlyingType(this.lhsBaseType);
            }
            if (this.rhsRootType == null)
            {
                this.rhsRootType = Enum.GetUnderlyingType(this.rhsBaseType);
            }
            switch (this.op)
            {
            case CodeBinaryOperatorType.Add:
                if ((parameters[0] != null) && (parameters[1] != null))
                {
                    literal  = ArithmeticLiteral.MakeLiteral(this.lhsRootType, parameters[0]);
                    literal2 = ArithmeticLiteral.MakeLiteral(this.rhsRootType, parameters[1]);
                    obj2     = literal.Add(literal2);
                    obj2     = Executor.AdjustType(obj2.GetType(), obj2, this.resultBaseType);
                    if (this.resultIsNullable)
                    {
                        obj2 = Activator.CreateInstance(this.resultType, new object[] { obj2 });
                    }
                    return(obj2);
                }
                return(null);

            case CodeBinaryOperatorType.Subtract:
                if ((parameters[0] != null) && (parameters[1] != null))
                {
                    literal  = ArithmeticLiteral.MakeLiteral(this.resultRootType, Executor.AdjustType(this.lhsRootType, parameters[0], this.resultRootType));
                    literal2 = ArithmeticLiteral.MakeLiteral(this.resultRootType, Executor.AdjustType(this.rhsRootType, parameters[1], this.resultRootType));
                    obj2     = literal.Subtract(literal2);
                    obj2     = Executor.AdjustType(obj2.GetType(), obj2, this.resultBaseType);
                    if (this.resultIsNullable)
                    {
                        obj2 = Activator.CreateInstance(this.resultType, new object[] { obj2 });
                    }
                    return(obj2);
                }
                return(null);

            case CodeBinaryOperatorType.ValueEquality:
                literal3 = Literal.MakeLiteral(this.lhsRootType, parameters[0]);
                literal4 = Literal.MakeLiteral(this.rhsRootType, parameters[1]);
                return(literal3.Equal(literal4));

            case CodeBinaryOperatorType.LessThan:
                literal3 = Literal.MakeLiteral(this.lhsRootType, parameters[0]);
                literal4 = Literal.MakeLiteral(this.rhsRootType, parameters[1]);
                return(literal3.LessThan(literal4));

            case CodeBinaryOperatorType.LessThanOrEqual:
                literal3 = Literal.MakeLiteral(this.lhsRootType, parameters[0]);
                literal4 = Literal.MakeLiteral(this.rhsRootType, parameters[1]);
                return(literal3.LessThanOrEqual(literal4));

            case CodeBinaryOperatorType.GreaterThan:
                literal3 = Literal.MakeLiteral(this.lhsRootType, parameters[0]);
                literal4 = Literal.MakeLiteral(this.rhsRootType, parameters[1]);
                return(literal3.GreaterThan(literal4));

            case CodeBinaryOperatorType.GreaterThanOrEqual:
                literal3 = Literal.MakeLiteral(this.lhsRootType, parameters[0]);
                literal4 = Literal.MakeLiteral(this.rhsRootType, parameters[1]);
                return(literal3.GreaterThanOrEqual(literal4));
            }
            throw new RuleEvaluationException(string.Format(CultureInfo.CurrentCulture, Messages.BinaryOpNotSupported, new object[] { this.op.ToString() }));
        }