protected ViewAdapter(InputCollectionWrapper <Tin> input, LinqContinuousCollection <Tout> output) { if (input == null) { throw new ArgumentNullException("input"); } if (output == null) { throw new ArgumentNullException("output"); } _input = input; _output = new OutputCollectionWrapper <Tout>(output); output.SourceAdapter = this; // Must be referenced by this instance: _collectionChangedDelegate = delegate(object sender, NotifyCollectionChangedEventArgs args) { OnInputCollectionChanged(args); }; _propertyChangedDelegate = delegate(object sender, PropertyChangedEventArgs args) { OnCollectionItemPropertyChanged((Tin)sender, args.PropertyName); }; new WeakCollectionChangedHandler(input.InnerAsNotifier, _collectionChangedDelegate); foreach (Tin item in this.InputCollection) { SubscribeToItem(item); } }
public GroupingViewAdapter( InputCollectionWrapper <TSource> source, LinqContinuousCollection <GroupedContinuousCollection <TKey, TElement> > output, Expression <Func <TSource, TKey> > keySelector, Expression <Func <TSource, TElement> > elementSelector, IEqualityComparer <TKey> comparer) : base(source, output, ExpressionPropertyAnalyzer.GetReferencedPropertyNames(keySelector)[typeof(TSource)]) { /* * : base(source, output, * ExpressionPropertyAnalyzer.GetReferencedPropertyNames(keySelector)[typeof(TSource)]. * */ if (elementSelector == null) { throw new ArgumentNullException("elementSelector"); } _keySelector = keySelector.Compile(); _elementSelector = elementSelector.Compile(); if (comparer == null) { comparer = EqualityComparer <TKey> .Default; } _comparer = comparer; foreach (TSource item in this.InputCollection) { AddItem(item, -1); } }
public ExceptViewAdapter(InputCollectionWrapper <T> input1, InputCollectionWrapper <T> input2, LinqContinuousCollection <T> output) { if (input1 == null) { throw new ArgumentNullException("input1"); } if (input2 == null) { throw new ArgumentNullException("input2"); } if (output == null) { throw new ArgumentNullException("output"); } this.Input1 = input1; this.Input2 = input2; this.Output = new OutputCollectionWrapper <T>(output); // Backreference output.SourceAdapter = this; // Subscribe to collection / property change CollectionChangedEventManager.AddListener(input1.InnerAsNotifier, this); CollectionChangedEventManager.AddListener(input2.InnerAsNotifier, this); // Evaluate changes ReEvaluate(); }
protected SmartViewAdapter(InputCollectionWrapper <TInput> input, LinqContinuousCollection <TOutput> output, HashSet <string> monitoredProperties) { if (input == null) { throw new ArgumentNullException("input"); } if (output == null) { throw new ArgumentNullException("output"); } _input = input; _output = new OutputCollectionWrapper <TOutput>(output); _monitoredProperties = monitoredProperties; output.SourceAdapter = this; // Must be referenced by this instance: foreach (TInput item in _input.InnerAsList) { SubscribeToItem(item); } CollectionChangedEventManager.AddListener( _input.InnerAsNotifier, this); }
private static ReadOnlyContinuousCollection <T> Where <T>( InputCollectionWrapper <T> source, Expression <Func <T, bool> > filterExpr) where T : INotifyPropertyChanged { LinqContinuousCollection <T> output = new LinqContinuousCollection <T>(); new SmartFilterAdapter <T>(source, output, filterExpr); return(output); }
public DistinctViewAdapter(InputCollectionWrapper <TSource> source, LinqContinuousCollection <TSource> output, IEqualityComparer <TSource> comparer) : base(source, output) { _comparer = comparer; ReEvaluate(); }
private static ReadOnlyContinuousCollection <TSource> Except <TSource>( InputCollectionWrapper <TSource> input1, InputCollectionWrapper <TSource> input2) { var output = new LinqContinuousCollection <TSource>(); new ExceptViewAdapter <TSource>(input1, input2, output); return(output); }
private static ReadOnlyContinuousCollection <TResult> SelectMany <TSource, TResult>( InputCollectionWrapper <TSource> source, Func <TSource, IEnumerable <TResult> > selector) where TSource : INotifyPropertyChanged { LinqContinuousCollection <TResult> output = new LinqContinuousCollection <TResult>(); new SelectingManyViewAdapter <TSource, TResult>(source, output, selector); return(output); }
/// <summary> /// Private static method for Distinct operating using the /// default IEqualityComparer of T. /// </summary> /// <typeparam name="TSource"></typeparam> /// <param name="source"></param> /// <returns></returns> private static ReadOnlyContinuousCollection <TSource> Distinct <TSource>( InputCollectionWrapper <TSource> source) where TSource : INotifyPropertyChanged { LinqContinuousCollection <TSource> output = new LinqContinuousCollection <TSource>(); new DistinctViewAdapter <TSource>(source, output); return(output); }
private static ReadOnlyContinuousCollection <TSource> OrderByDescending <TSource, TKey>( InputCollectionWrapper <TSource> source, Expression <Func <TSource, TKey> > keySelector) where TSource : INotifyPropertyChanged where TKey : IComparable { LinqContinuousCollection <TSource> output = new LinqContinuousCollection <TSource>(); new SortingViewAdapter <TSource, TKey>( source, output, keySelector, true); return(output); }
public FilteringViewAdapter(InputCollectionWrapper <T> input, LinqContinuousCollection <T> output, Func <T, bool> predicateFunc) : base(input, output) { _predicate = predicateFunc; foreach (T item in this.InputCollection) { if (_predicate(item)) { this.OutputCollection.Add(item); } } }
private static ReadOnlyContinuousCollection <GroupedContinuousCollection <TKey, TElement> > GroupBy <TSource, TKey, TElement>( InputCollectionWrapper <TSource> source, Expression <Func <TSource, TKey> > keySelector, Expression <Func <TSource, TElement> > elementSelector, IEqualityComparer <TKey> comparer) where TSource : INotifyPropertyChanged where TKey : IComparable { LinqContinuousCollection <GroupedContinuousCollection <TKey, TElement> > output = new LinqContinuousCollection <GroupedContinuousCollection <TKey, TElement> >(); new GroupingViewAdapter <TSource, TKey, TElement>(source, output, keySelector, elementSelector, comparer); return(output); }
public SortingViewAdapter(InputCollectionWrapper <TSource> input, LinqContinuousCollection <TSource> output, Expression <Func <TSource, TKey> > keySelectorExpr, bool descending) : base(input, output, ExpressionPropertyAnalyzer.GetReferencedPropertyNames(keySelectorExpr)[typeof(TSource)]) { if (keySelectorExpr == null) { throw new ArgumentNullException("keySelectorExpr"); } _compareFunc = new FuncComparer <TSource, TKey>(keySelectorExpr.Compile(), descending); SetComparerChain(_compareFunc); FullSort(); // Because we do not know yet if we are last in chain. }
public SelectingViewAdapter(InputCollectionWrapper <TSource> input, LinqContinuousCollection <TResult> output, Func <TSource, TResult> func) : base(input, output) { _func = func; if (func == null) { throw new ArgumentNullException("func"); } foreach (TSource item in this.InputCollection) { this.OutputCollection.Add(func(item)); } }
public SelectingManyViewAdapter(InputCollectionWrapper <TSource> input, LinqContinuousCollection <TResult> output, Func <TSource, IEnumerable <TResult> > func) : base(input, output) { _func = func; if (func == null) { throw new ArgumentNullException("func"); } foreach (TSource inItem in this.InputCollection) { List <TResult> outList = new List <TResult>(func(inItem)); this.OutputCollection.AddRange(outList); _collectionLengths.Add(outList.Count); } }
public SmartFilterAdapter( InputCollectionWrapper <T> input, LinqContinuousCollection <T> output, Expression <Func <T, bool> > predicateExpr) : base(input, output, ExpressionPropertyAnalyzer.GetReferencedPropertyNames(predicateExpr)[typeof(T)]) { _predicate = predicateExpr.Compile(); foreach (T item in input.InnerAsList) { if (_predicate(item)) { OutputCollection.Add(item); } } }
public DistinctViewAdapter(InputCollectionWrapper <TSource> source, LinqContinuousCollection <TSource> output) : base(source, output) { ReEvaluate(); }