Пример #1
0
        /// <summary>
        /// Parse the level option in the expand option text.
        /// </summary>
        /// <returns>The level option for expand in long type</returns>
        private long?ParseInnerLevel()
        {
            long?levelsOption = null;

            // advance to the equal sign
            this.lexer.NextToken();
            string levelsText = UriParserHelper.ReadQueryOption(this.lexer);
            long   level;

            if (string.Equals(
                    ExpressionConstants.KeywordMax,
                    levelsText,
                    this.enableCaseInsensitiveBuiltinIdentifier ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal))
            {
                levelsOption = long.MinValue;
            }
            else if (!long.TryParse(levelsText, NumberStyles.None, CultureInfo.InvariantCulture, out level) || level < 0)
            {
                throw new ODataException(ODataErrorStrings.UriSelectParser_InvalidLevelsOption(levelsText));
            }
            else
            {
                levelsOption = level;
            }

            return(levelsOption);
        }
Пример #2
0
        /// <summary>
        /// Parse the select option in the select/expand option text.
        /// </summary>
        /// <param name="pathToken">The path segment token</param>
        /// <returns>The select option for select/expand</returns>
        private SelectToken ParseInnerSelect(PathSegmentToken pathToken)
        {
            // advance to the equal sign
            this.lexer.NextToken();
            string selectText = UriParserHelper.ReadQueryOption(this.lexer);

            IEdmStructuredType targetStructuredType = null;

            if (this.resolver != null && this.parentStructuredType != null)
            {
                var parentProperty = this.resolver.ResolveProperty(parentStructuredType, pathToken.Identifier);

                // It is a property, need to find the type.
                // or for select query like: $select=Address($expand=City)
                if (parentProperty != null)
                {
                    targetStructuredType = parentProperty.Type.ToStructuredType();
                }
            }

            SelectExpandParser innerSelectParser = new SelectExpandParser(
                resolver,
                selectText,
                targetStructuredType,
                this.maxRecursionDepth - 1,
                this.enableCaseInsensitiveBuiltinIdentifier,
                this.enableNoDollarQueryOptions);

            return(innerSelectParser.ParseSelect());
        }
Пример #3
0
        /// <summary>
        /// Parse the expand option in the select/expand option text.
        /// </summary>
        /// <param name="pathToken">The path segment token</param>
        /// <returns>The expand option for select/expand</returns>
        private ExpandToken ParseInnerExpand(PathSegmentToken pathToken)
        {
            // advance to the equal sign
            this.lexer.NextToken();

            string expandText = UriParserHelper.ReadQueryOption(this.lexer);

            IEdmStructuredType targetStructuredType = null;

            if (this.resolver != null && this.parentStructuredType != null)
            {
                var parentProperty = this.resolver.ResolveProperty(parentStructuredType, pathToken.Identifier);

                // it is a property, need to find the type.
                // Like $expand=Friends($expand=Trips($expand=*)), when expandText becomes "Trips($expand=*)",
                // find navigation property Trips of Friends, then get Entity type of Trips.
                // or for select query like: $select=Address($expand=City)
                if (parentProperty != null)
                {
                    targetStructuredType = parentProperty.Type.ToStructuredType();
                }
            }

            SelectExpandParser innerExpandParser = new SelectExpandParser(
                resolver,
                expandText,
                targetStructuredType,
                this.maxRecursionDepth - 1,
                this.enableCaseInsensitiveBuiltinIdentifier,
                this.enableNoDollarQueryOptions);

            return(innerExpandParser.ParseExpand());
        }
Пример #4
0
        /// <summary>
        /// Parse the apply option in the expand option text.
        /// </summary>
        /// <returns>The apply option for expand</returns>
        private IEnumerable <QueryToken> ParseInnerApply()
        {
            this.lexer.NextToken();
            string applyText = UriParserHelper.ReadQueryOption(this.lexer);

            UriQueryExpressionParser applyParser = new UriQueryExpressionParser(this.MaxOrderByDepth, enableCaseInsensitiveBuiltinIdentifier);

            return(applyParser.ParseApply(applyText));
        }
Пример #5
0
        /// <summary>
        /// Parse the compute option in the expand option text.
        /// </summary>
        /// <returns>The compute option for expand</returns>
        private ComputeToken ParseInnerCompute()
        {
            this.lexer.NextToken();
            string computeText = UriParserHelper.ReadQueryOption(this.lexer);

            UriQueryExpressionParser computeParser = new UriQueryExpressionParser(this.MaxOrderByDepth, enableCaseInsensitiveBuiltinIdentifier);

            return(computeParser.ParseCompute(computeText));
        }
Пример #6
0
        /// <summary>
        /// Parse the orderby option in the select/expand option text.
        /// </summary>
        /// <returns>The orderby option for select/expand</returns>
        private IEnumerable <OrderByToken> ParseInnerOrderBy()
        {
            // advance to the equal sign
            this.lexer.NextToken();
            string orderByText = UriParserHelper.ReadQueryOption(this.lexer);

            UriQueryExpressionParser orderbyParser = new UriQueryExpressionParser(this.MaxOrderByDepth, enableCaseInsensitiveBuiltinIdentifier);

            return(orderbyParser.ParseOrderBy(orderByText));
        }
Пример #7
0
        /// <summary>
        /// Parse the search option in the select/expand option text.
        /// </summary>
        /// <returns>The search option for select/expand</returns>
        private QueryToken ParseInnerSearch()
        {
            // advance to the equal sign
            this.lexer.NextToken();
            string searchText = UriParserHelper.ReadQueryOption(this.lexer);

            SearchParser searchParser = new SearchParser(this.MaxSearchDepth);

            return(searchParser.ParseSearch(searchText));
        }
Пример #8
0
        /// <summary>
        /// Parse the filter option in the select/expand option text.
        /// </summary>
        /// <returns>The filter option for select/expand</returns>
        private QueryToken ParseInnerFilter()
        {
            // advance to the equal sign
            this.lexer.NextToken();
            string filterText = UriParserHelper.ReadQueryOption(this.lexer);

            UriQueryExpressionParser filterParser = new UriQueryExpressionParser(this.MaxFilterDepth, enableCaseInsensitiveBuiltinIdentifier);

            return(filterParser.ParseFilter(filterText));
        }
Пример #9
0
        /// <summary>
        /// Parse the search option in the $count segment.
        /// </summary>
        /// <returns>The search option for the $count segment.</returns>
        private QueryToken ParseInnerSearch()
        {
            // advance to the equal sign
            this.lexer.NextToken();
            string searchText = UriParserHelper.ReadQueryOption(this.lexer);

            SearchParser searchParser = new SearchParser(ODataUriParserSettings.DefaultSearchLimit);

            return(searchParser.ParseSearch(searchText));
        }
Пример #10
0
        /// <summary>
        /// Parse the filter option in the $count segment.
        /// </summary>
        /// <returns>The filter option for the $count segment.</returns>
        private QueryToken ParseInnerFilter()
        {
            // advance to the equal sign
            this.lexer.NextToken();
            string filterText = UriParserHelper.ReadQueryOption(this.lexer);

            UriQueryExpressionParser filterParser = new UriQueryExpressionParser(ODataUriParserSettings.DefaultFilterLimit, this.UriQueryExpressionParser.EnableCaseInsensitiveBuiltinIdentifier);

            return(filterParser.ParseFilter(filterText));
        }
Пример #11
0
        /// <summary>
        /// Parse the skip option in the select/expand option text.
        /// </summary>
        /// <returns>The skip option for select/expand</returns>
        private long?ParseInnerSkip()
        {
            // advance to the equal sign
            this.lexer.NextToken();
            string skipText = UriParserHelper.ReadQueryOption(this.lexer);

            // TryParse requires a non-nullable non-negative long.
            long skip;

            if (!long.TryParse(skipText, out skip) || skip < 0)
            {
                throw new ODataException(ODataErrorStrings.UriSelectParser_InvalidSkipOption(skipText));
            }

            return(skip);
        }
Пример #12
0
        /// <summary>
        /// Parse the count option in the select/expand option text.
        /// </summary>
        /// <returns>The count option for select/expand</returns>
        private bool?ParseInnerCount()
        {
            // advance to the equal sign
            this.lexer.NextToken();
            string countText = UriParserHelper.ReadQueryOption(this.lexer);

            switch (countText)
            {
            case ExpressionConstants.KeywordTrue:
                return(true);

            case ExpressionConstants.KeywordFalse:
                return(false);

            default:
                throw new ODataException(ODataErrorStrings.UriSelectParser_InvalidCountOption(countText));
            }
        }