//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
// [....]
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Data;
using System.Linq;
using System.Diagnostics;
namespace System.Data
{
///
/// This class represents a combined sort expression build using mutiple sort expressions.
///
///
internal class SortExpressionBuilder : IComparer>
{
/**
* This class ensures multiple orderby/thenbys are handled correctly. Its semantics is as follows:
*
* Query 1:
* orderby a
* thenby b
* orderby c
* orderby d
* thenby e
*
* is equivalent to:
*
* Query 2:
* orderby d
* thenby e
* thenby c
* thenby a
* thenby b
*
**/
//Selectors and comparers are mapped using the index in the list.
//E.g: _comparers[i] is used with _selectors[i]
LinkedList> _selectors = new LinkedList>();
LinkedList> _comparers = new LinkedList>();
LinkedListNode> _currentSelector = null;
LinkedListNode> _currentComparer = null;
///
/// Adds a sorting selector/comparer in the correct order
///
internal void Add(Func keySelector, Comparison