Exemple #1
0
 private void setupComparer(int count, IDataRowComparer comparer)
 {
     for (var i = 1; i <= count; i++)
     {
         var columnName = "Column" + i;
         comparer.MatchOn <string>(columnName);
     }
 }
Exemple #2
0
 public CompositeComparer(IDataRowComparer comparer1, IDataRowComparer comparer2)
 {
     Debug.Assert(comparer1 != null);
     Debug.Assert(comparer2 != null);
     Debug.Assert(comparer1.ModelType == comparer2.ModelType);
     _comparer1 = comparer1;
     _comparer2 = comparer2;
 }
Exemple #3
0
 /// <summary>
 /// Adds sorting comparer to exiting DataRow comparer.
 /// </summary>
 /// <param name="orderBy">The existing DataRow comparer.</param>
 /// <param name="thenBy">The sorting comparer to add.</param>
 /// <returns>The result DataRow comparer.</returns>
 public static IDataRowComparer ThenBy(this IDataRowComparer orderBy, IDataRowComparer thenBy)
 {
     orderBy.VerifyNotNull(nameof(orderBy));
     thenBy.VerifyNotNull(nameof(thenBy));
     if (orderBy.ModelType != thenBy.ModelType)
     {
         throw new ArgumentException(DiagnosticMessages.DataRowComparer_DifferentDataRowModel, nameof(thenBy));
     }
     return(ComparerBase.Create(orderBy, thenBy));
 }
Exemple #4
0
        /// <summary>
        /// Adds additional sorting column to existing DataRow comparer.
        /// </summary>
        /// <typeparam name="T">Data type of column.</typeparam>
        /// <param name="orderBy">The existing DataRow comparer.</param>
        /// <param name="column">The additional sorting column.</param>
        /// <param name="direction">The sorting direction.</param>
        /// <param name="comparer">Data value comparer.</param>
        /// <returns>The result DataRow comparer.</returns>
        public static IDataRowComparer ThenBy <T>(this IDataRowComparer orderBy, Column <T> column, SortDirection direction = SortDirection.Ascending, IComparer <T> comparer = null)
        {
            orderBy.VerifyNotNull(nameof(orderBy));
            var thenBy = DataRow.OrderBy(column, direction, comparer);

            if (orderBy.ModelType != thenBy.ModelType)
            {
                throw new ArgumentException(DiagnosticMessages.DataRowComparer_DifferentDataRowModel, nameof(column));
            }
            return(ComparerBase.Create(orderBy, thenBy));
        }
Exemple #5
0
            private static IComparer <DataRow> GetOrderBy(IReadOnlyList <IColumnComparer> orderBy)
            {
                if (orderBy == null || orderBy.Count == 0)
                {
                    return(null);
                }

                IDataRowComparer result = orderBy[0];

                for (int i = 1; i < orderBy.Count; i++)
                {
                    result = result.ThenBy(orderBy[i]);
                }

                return(result);
            }
Exemple #6
0
 public static IDataRowComparer Create(IDataRowComparer comparer1, IDataRowComparer comparer2)
 {
     return(new CompositeComparer(comparer1, comparer2));
 }