Esempio n. 1
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="source"></param>
 /// <param name="keyselector"></param>
 public OrderThenBySequence(数据结构.IEnumerable <TSource> source, 内置委托.Func <TSource, TKey> keyselector, 系统内置接口.IComparer <TKey> comparer)
 {
     if (source == null)
     {
         throw new Exception("需要排序的数据源不能为空");
     }
     if (keyselector == null)
     {
         throw new Exception("需要排序的字段不能为空");
     }
     this.comparer    = comparer;
     this.source      = source;
     this.keyselector = keyselector;
     this.parent      = null;//如果是orderby那么就说明只需要创建一个序列,也就没有了父级序列
     //如果用户没有定义默认的比较器就使用系统默认的比较器
     if (this.comparer == null)
     {
         数据结构.Comparer <TKey> comparerclass = new Comparer <TKey>();
         this.comparer = comparerclass.Default;
     }
 }
Esempio n. 2
0
 /// <summary>
 ///当OrderBy之后进行ThenBy的序列的创建的时候调用的方法,接受必须进行OrderBy之后的参数(IOrderThenBy类型的参数)
 /// </summary>
 /// <param name="afterorderbysource">IOrderThenBy的数据类型</param>
 /// <param name="thenbyKeySelector">ThenBy需要执行的方法</param>
 /// <returns></returns>
 public 数据结构.OrderThenBySequence <TSource, TKey> CreateForThenBy(内置委托.Func <TSource, TKey> thenbyKeySelector, 系统内置接口.IComparer <TKey> comparer)
 {
     数据结构.OrderThenBySequence <TSource, TKey> thenbysource = new OrderThenBySequence <TSource, TKey>(source, thenbyKeySelector, comparer);
     thenbysource.parent = this;//this表示的当前的类,某个类的实例的对象.方法,那么在这个方法中的this就是这个 实例对象
     return(thenbysource);
 }