using System; using System.Collections.Generic; namespace CPF.ReoGrid { internal class CellComparerAdapter : IComparer { public CellComparerAdapter(Func comparerFunc, SortOrder order) { if (comparerFunc == null) { throw new ArgumentNullException("comparerFunc"); } this.comparerFunc = comparerFunc; this.sign = ((order == SortOrder.Ascending) ? 1 : -1); } public int Compare(object x, object y) { string text = x as string; bool flag = text != null && string.IsNullOrEmpty(text); if (flag) { x = null; } string text2 = y as string; bool flag2 = text2 != null && string.IsNullOrEmpty(text2); if (flag2) { y = null; } bool flag3 = x == null && y == null; int result; if (flag3) { result = 0; } else { bool flag4 = x != null && y == null; if (flag4) { result = -this.sign; } else { bool flag5 = x == null; if (flag5) { result = this.sign; } else { result = this.comparerFunc(x, y); } } } return result; } private readonly Func comparerFunc; private readonly int sign; } }