private void DoBoolean(BooleanExpression expression, CodeBinaryOperatorType operation)
        {
            var leftArgs = VisitChild(expression.Left, new CodeDomArg() { Scope = _codeStack.Peek().Scope });
            var rightArgs = VisitChild(expression.Right, new CodeDomArg() { Scope = _codeStack.Peek().Scope });

            Type leftType = Type.GetType(leftArgs.Scope.CodeDomReference.BaseType);
            Type rightType = Type.GetType(rightArgs.Scope.CodeDomReference.BaseType);
            if (leftType != rightType)
            {
                if (leftType == typeof(string))
                {
                    var primitive = TablePrimitive.FromType(rightType);
                    leftArgs.CodeExpression = primitive.ToNative(leftArgs.CodeExpression);
                }
                else if(rightType == typeof(string))
                {
                    var primitive = TablePrimitive.FromType(leftType);
                    rightArgs.CodeExpression = primitive.ToNative(rightArgs.CodeExpression);
                }
            }

            if (leftArgs.Tag != null)
                _codeStack.Peek().Tag = leftArgs.Tag;
            if (rightArgs.Tag != null)
                _codeStack.Peek().Tag = rightArgs.Tag;

            _codeStack.Peek().CodeExpression = new CodeBinaryOperatorExpression(leftArgs.CodeExpression, operation, rightArgs.CodeExpression);
        }
Exemplo n.º 2
0
        private void DoBooleanAggregate(BooleanExpression expression, CodeBinaryOperatorType operation)
        {
            var leftArgs = VisitChild(expression.Left, new CodeDomArg() { Scope = _codeStack.Peek().Scope });
            var rightArgs = VisitChild(expression.Right, new CodeDomArg() { Scope = _codeStack.Peek().Scope });

            if (leftArgs.Tag != null)
                _codeStack.Peek().Tag = leftArgs.Tag;
            if (rightArgs.Tag != null)
                _codeStack.Peek().Tag = rightArgs.Tag;

            _codeStack.Peek().CodeExpression = new CodeBinaryOperatorExpression(leftArgs.CodeExpression, operation, rightArgs.CodeExpression);
        }