Esempio n. 1
0
        /// <summary>
        /// Visits a <see cref="QueryToken"/> in the lexical tree and binds it to metadata producing a semantic <see cref="QueryNode"/>.
        /// </summary>
        /// <param name="token">The query token on the input.</param>
        /// <returns>The bound query node output.</returns>
        protected internal QueryNode Bind(QueryToken token)
        {
            ExceptionUtils.CheckArgumentNotNull(token, "token");
            QueryNode result;

            switch (token.Kind)
            {
            case QueryTokenKind.Any:
                result = this.BindAnyAll((AnyToken)token);
                break;

            case QueryTokenKind.All:
                result = this.BindAnyAll((AllToken)token);
                break;

            case QueryTokenKind.InnerPath:
                result = this.BindInnerPathSegment((InnerPathToken)token);
                break;

            case QueryTokenKind.Literal:
                result = this.BindLiteral((LiteralToken)token);
                break;

            case QueryTokenKind.BinaryOperator:
                result = this.BindBinaryOperator((BinaryOperatorToken)token);
                break;

            case QueryTokenKind.UnaryOperator:
                result = this.BindUnaryOperator((UnaryOperatorToken)token);
                break;

            case QueryTokenKind.EndPath:
                result = this.BindEndPath((EndPathToken)token);
                break;

            case QueryTokenKind.FunctionCall:
                result = this.BindFunctionCall((FunctionCallToken)token);
                break;

            case QueryTokenKind.DottedIdentifier:
                result = this.BindCast((DottedIdentifierToken)token);
                break;

            case QueryTokenKind.RangeVariable:
                result = this.BindRangeVariable((RangeVariableToken)token);
                break;

            case QueryTokenKind.FunctionParameter:
                result = this.BindFunctionParameter((FunctionParameterToken)token);
                break;

            default:
                throw new ODataException(ODataErrorStrings.MetadataBinder_UnsupportedQueryTokenKind(token.Kind));
            }

            if (result == null)
            {
                throw new ODataException(ODataErrorStrings.MetadataBinder_BoundNodeCannotBeNull(token.Kind));
            }

            return(result);
        }