/// <summary> /// Clones the SortexpressionBuilder and returns a new object /// that points to same comparer and selectors (in the same order). /// </summary> /// <returns></returns> internal SortExpressionBuilder<T> Clone() { SortExpressionBuilder<T> builder = new SortExpressionBuilder<T>(); foreach (Func<T, object> selector in _selectors) { if (selector == _currentSelector.Value) { builder._currentSelector = builder._selectors.AddLast(selector); } else { builder._selectors.AddLast(selector); } } foreach (Comparison<object> comparer in _comparers) { if (comparer == _currentComparer.Value) { builder._currentComparer = builder._comparers.AddLast(comparer); } else { builder._comparers.AddLast(comparer); } } return builder; }
/// <summary> /// Clones the SortExpressinBuilder and casts to type TResult. /// </summary> internal SortExpressionBuilder <TResult> CloneCast <TResult>() { SortExpressionBuilder <TResult> builder = new SortExpressionBuilder <TResult>(); foreach (Func <T, object> selector in _selectors) { if (selector == _currentSelector.Value) { builder._currentSelector = builder._selectors.AddLast(r => selector((T)(object)r)); } else { builder._selectors.AddLast(r => selector((T)(object)r)); } } foreach (Comparison <object> comparer in _comparers) { if (comparer == _currentComparer.Value) { builder._currentComparer = builder._comparers.AddLast(comparer); } else { builder._comparers.AddLast(comparer); } } return(builder); }
/// <summary> /// Clones the SortexpressionBuilder and returns a new object /// that points to same comparer and selectors (in the same order). /// </summary> internal SortExpressionBuilder <T> Clone() { SortExpressionBuilder <T> builder = new SortExpressionBuilder <T>(); foreach (Func <T, object> selector in _selectors) { if (selector == _currentSelector !.Value) { builder._currentSelector = builder._selectors.AddLast(selector); }
/// <summary> /// /// </summary> /// <param name="table">Table from which to create the view</param> /// <param name="predicate_system">User-provided predicate but in the form of System.Predicate<DataRow> /// Predicates are being replicated in different forms so that nulls can be passed in. /// For e.g. when user provides null predicate, base.Predicate should be set to null. I cant do that in the constructor initialization /// if I will have to create System.Predicate delegate from Func. /// </param> /// <param name="comparison">The comparer function of DataRow to be used for sorting. </param> /// <param name="comparerKeyRow">A comparer function that compares a Key value to DataRow.</param> /// <param name="sortExpressionBuilder">Combined sort expression build using mutiple sort expressions.</param> internal LinqDataView( DataTable table, Predicate <DataRow> predicate_system, Comparison <DataRow> comparison, Func <object, DataRow, int> comparerKeyRow, SortExpressionBuilder <DataRow> sortExpressionBuilder) : base(table, predicate_system, comparison, DataViewRowState.CurrentRows) { this.sortExpressionBuilder = (sortExpressionBuilder == null) ? this.sortExpressionBuilder : sortExpressionBuilder; this.comparerKeyRow = comparerKeyRow; }
/// <summary> /// Constructs a LinkDataView and its parent DataView. /// Does not create index on the DataView since filter and sort expressions are not yet provided. /// </summary> /// <param name="table">The input table from which LinkDataView is to be created.</param> internal LinqDataView(DataTable table, SortExpressionBuilder <DataRow> sortExpressionBuilder) : base(table) { Debug.Assert(table != null, "null DataTable"); this.sortExpressionBuilder = sortExpressionBuilder ?? new SortExpressionBuilder <DataRow>(); }