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);
        }
Exemple #5
0
 public virtual bool Equals(ISortParserResultExpression other)
 {
     if (other == null)
     {
         return(false);
     }
     if (object.ReferenceEquals(this, other))
     {
         return(true);
     }
     if (!string.Equals(this.Name, other.Name, StringComparison.OrdinalIgnoreCase))
     {
         return(false);
     }
     if (this.Operator != other.Operator)
     {
         return(false);
     }
     if (!object.Equals(this.Child, other.Child))
     {
         return(false);
     }
     return(true);
 }
 public abstract bool TryParse(string sort, out ISortParserResultExpression expression);
Exemple #7
0
 public SortParserResultExpression(string name, SortParserResultOperator @operator, ISortParserResultExpression child) : this(name, @operator)
 {
     this.Child = child;
 }