Beispiel #1
0
        private List <ValueTableSortRule> GetSortRules(string Columns)
        {
            string[] a_columns = Columns.Split(',');

            List <ValueTableSortRule> Rules = new List <ValueTableSortRule>();

            foreach (string column in a_columns)
            {
                string[] description = column.Trim().Split(' ');
                if (description.Count() == 0)
                {
                    throw RuntimeException.PropNotFoundException(""); // TODO: WrongColumnNameException
                }
                ValueTableSortRule Desc = new ValueTableSortRule();
                Desc.Column = this.Columns.FindColumnByName(description[0]);

                if (description.Count() > 1)
                {
                    if (String.Compare(description[1], "DESC", true) == 0 || String.Compare(description[1], "УБЫВ", true) == 0)
                    {
                        Desc.direction = -1;
                    }
                }
                else
                {
                    Desc.direction = 1;
                }

                Rules.Add(Desc);
            }

            return(Rules);
        }
Beispiel #2
0
            private int OneCompare(ValueTableRow x, ValueTableRow y, ValueTableSortRule Rule)
            {
                IValue xValue = x.Get(Rule.Column);
                IValue yValue = y.Get(Rule.Column);

                int result = _comparer.Compare(xValue, yValue) * Rule.direction;

                return(result);
            }