Example #1
0
        /// <summary>
        /// Retrieve SingleValueNode operand from given token.
        /// </summary>
        /// <param name="unaryOperatorToken">The token</param>
        /// <returns>the SingleValueNode operand</returns>
        private SingleValueNode GetOperandFromToken(UnaryOperatorToken unaryOperatorToken)
        {
            SingleValueNode operand = this.bindMethod(unaryOperatorToken.Operand) as SingleValueNode;

            if (operand == null)
            {
                throw new ODataException(ODataErrorStrings.MetadataBinder_UnaryOperatorOperandNotSingleValue(unaryOperatorToken.OperatorKind.ToString()));
            }

            return(operand);
        }
Example #2
0
        /// <summary>
        /// Binds a unary operator token.
        /// </summary>
        /// <param name="unaryOperatorToken">The unary operator token to bind.</param>
        /// <returns>The bound unary operator token.</returns>
        internal QueryNode BindUnaryOperator(UnaryOperatorToken unaryOperatorToken)
        {
            ExceptionUtils.CheckArgumentNotNull(unaryOperatorToken, "unaryOperatorToken");

            SingleValueNode operand = this.GetOperandFromToken(unaryOperatorToken);

            IEdmTypeReference typeReference = UnaryOperatorBinder.PromoteOperandType(operand, unaryOperatorToken.OperatorKind);

            Debug.Assert(typeReference == null || typeReference.IsODataPrimitiveTypeKind(), "Only primitive types should be able to get here.");
            operand = MetadataBindingUtils.ConvertToTypeIfNeeded(operand, typeReference);

            return(new UnaryOperatorNode(unaryOperatorToken.OperatorKind, operand));
        }
Example #3
0
        /// <summary>
        /// Binds a unary operator token.
        /// </summary>
        /// <param name="unaryOperatorToken">The unary operator token to bind.</param>
        /// <returns>The bound unary operator token.</returns>
        protected virtual QueryNode BindUnaryOperator(UnaryOperatorToken unaryOperatorToken)
        {
            UnaryOperatorBinder unaryOperatorBinder = new UnaryOperatorBinder(this.Bind);

            return(unaryOperatorBinder.BindUnaryOperator(unaryOperatorToken));
        }
 /// <summary>
 /// Visits a UnaryOperatorToken
 /// </summary>
 /// <param name="tokenIn">The UnaryOperatorToken to bind</param>
 /// <returns>A UnaryOperatorNode bound to this UnaryOperatorToken</returns>
 public virtual T Visit(UnaryOperatorToken tokenIn)
 {
     throw new NotImplementedException();
 }