Exemple #1
0
        public override bool TryParse(string sort, out ISortParserResultExpression expression)
        {
            if (string.IsNullOrEmpty(sort))
            {
                expression = default(ISortParserResultExpression);
                return(false);
            }
            var parts = sort.Split(' ');

            if (parts.Length != 2)
            {
                expression = default(ISortParserResultExpression);
                return(false);
            }
            var name = default(string);

            if (!this.TryGetName(parts[0], out name))
            {
                expression = default(ISortParserResultExpression);
                return(false);
            }
            if (!string.Equals(parts[1], "num", StringComparison.OrdinalIgnoreCase))
            {
                expression = default(ISortParserResultExpression);
                return(false);
            }
            expression = new SortParserResultExpression(name, SortParserResultOperator.Numeric);
            return(true);
        }
Exemple #2
0
        public override bool TryParse(string sort, out ISortParserResultExpression expression)
        {
            var names = new[]
            {
                "random",
                Strings.RandomSortParserProvider_Random
            };

            if (names.Contains(sort, StringComparer.OrdinalIgnoreCase))
            {
                expression = new SortParserResultExpression(SortParserResultOperator.Random);
                return(true);
            }
            expression = default(ISortParserResultExpression);
            return(false);
        }
Exemple #3
0
            public override bool TryParse(string sort, out ISortParserResultExpression expression)
            {
                if (string.IsNullOrEmpty(sort))
                {
                    expression = default(ISortParserResultExpression);
                    return(false);
                }
                var name = default(string);

                if (!this.TryGetName(sort, out name))
                {
                    expression = default(ISortParserResultExpression);
                    return(false);
                }
                expression = new SortParserResultExpression(name);
                return(true);
            }
Exemple #4
0
        public override bool TryParse(string sort, out ISortParserResultExpression expression)
        {
            if (string.IsNullOrEmpty(sort))
            {
                expression = default(ISortParserResultExpression);
                return(false);
            }
            var parts = sort.Split(' ');

            if (parts.Length != 3)
            {
                expression = default(ISortParserResultExpression);
                return(false);
            }
            var name1 = default(string);

            if (!this.TryGetName(parts[0], out name1))
            {
                expression = default(ISortParserResultExpression);
                return(false);
            }
            var @operator = default(SortParserResultOperator);

            if (!Operators.TryGetValue(parts[1], out @operator))
            {
                expression = default(ISortParserResultExpression);
                return(false);
            }
            var name2 = default(string);

            if (!this.TryGetName(parts[2], out name2))
            {
                expression = default(ISortParserResultExpression);
                return(false);
            }
            expression = new SortParserResultExpression(
                name1,
                @operator,
                new SortParserResultExpression(
                    name2
                    )
                );
            return(true);
        }