Exemplo n.º 1
0
        string GetName(AllowedQueryOptions option)
        {
#pragma warning disable CA1308 // Normalize strings to uppercase
            var name = option.ToString().ToLowerInvariant();
#pragma warning restore CA1308
            return(Settings.NoDollarPrefix ? name : name.Insert(0, "$"));
        }
Exemplo n.º 2
0
        string GetName(AllowedQueryOptions option)
        {
            Contract.Requires(option == Filter || (option > Filter && option < Supported && ((int)option % 2 == 0)));

#pragma warning disable CA1308 // Normalize strings to uppercase
            var name = option.ToString().ToLowerInvariant();
#pragma warning restore CA1308
            return(Settings.NoDollarPrefix ? name : name.Insert(0, "$"));
        }
        /// <inheritdoc />
        public virtual string Describe(AllowedQueryOptions queryOption, ODataQueryOptionDescriptionContext context)
        {
            Arg.NotNull(context, nameof(context));

            if ((queryOption < Filter || queryOption > Supported) || (queryOption != Filter && ((int)queryOption % 2 != 0)))
            {
                throw new ArgumentException(SR.MultipleQueryOptionsNotAllowed, nameof(queryOption));
            }

            switch (queryOption)
            {
            case Filter:
                return(DescribeFilter(context));

            case Expand:
                return(DescribeExpand(context));

            case Select:
                return(DescribeSelect(context));

            case OrderBy:
                return(DescribeOrderBy(context));

            case Top:
                return(DescribeTop(context));

            case Skip:
                return(DescribeSkip(context));

            case Count:
                return(DescribeCount(context));
            }

#pragma warning disable CA1308 // Normalize strings to uppercase
            throw new ArgumentException(SR.UnsupportedQueryOption.FormatDefault(queryOption.ToString().ToLowerInvariant()), nameof(queryOption));
#pragma warning restore CA1308
        }
        /// <inheritdoc />
        public virtual string Describe(AllowedQueryOptions queryOption, ODataQueryOptionDescriptionContext context)
        {
            if ((queryOption < Filter || queryOption > Supported) || (queryOption != Filter && ((int)queryOption % 2 != 0)))
            {
                throw new ArgumentException(SR.MultipleQueryOptionsNotAllowed, nameof(queryOption));
            }

            return(queryOption switch
            {
                Filter => DescribeFilter(context),
                Expand => DescribeExpand(context),
                Select => DescribeSelect(context),
                OrderBy => DescribeOrderBy(context),
                Top => DescribeTop(context),
                Skip => DescribeSkip(context),
                Count => DescribeCount(context),
#pragma warning disable CA1308 // Normalize strings to uppercase
                _ => throw new ArgumentException(SR.UnsupportedQueryOption.FormatDefault(queryOption.ToString().ToLowerInvariant()), nameof(queryOption)),
#pragma warning restore CA1308
            });