Example #1
0
        public bool Evaluate(out IJsonValue value, IJSONDocument document)
        {
            //ReturnOperation consideration.

            if (_operation == ArithmeticOperation.None && _rhs == null)
            {
                return(_lhs.Evaluate(out value, document));
            }

            IComparable opValue;

            value = null;
            switch (_operation)
            {
            case ArithmeticOperation.Addition:
                opValue = _lhs.Add(_rhs, document);

                if (opValue == null)
                {
                    return(false);
                }

                value = JsonWrapper.Wrap(opValue);
                break;

            case ArithmeticOperation.Subtraction:

                opValue = _lhs.Subtract(_rhs, document);

                if (opValue == null)
                {
                    return(false);
                }
                value = JsonWrapper.Wrap(opValue);
                break;

            case ArithmeticOperation.Multiplication:

                opValue = _lhs.Multiply(_rhs, document);

                if (opValue == null)
                {
                    return(false);
                }

                value = JsonWrapper.Wrap(opValue);
                break;

            case ArithmeticOperation.Division:

                opValue = _lhs.Divide(_rhs, document);

                if (opValue == null)
                {
                    return(false);
                }

                value = JsonWrapper.Wrap(opValue);
                break;

            case ArithmeticOperation.Modulus:

                opValue = _lhs.Modulate(_rhs, document);

                if (opValue == null)
                {
                    return(false);
                }

                value = JsonWrapper.Wrap(opValue);
                break;
            }
            return(true);
        }