示例#1
0
        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);
            }
        }
示例#2
0
        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.
        }
示例#3
0
        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 SelectReadOnlyContinuousCollection(IList <TSource> list, Expression <Func <TSource, TResult> > selectorExpression)
            : base(list, ExpressionPropertyAnalyzer.Analyze(selectorExpression))
        {
            this.SelectorFunction = selectorExpression.CachedCompile();

            this.CurrentValues = new Dictionary <TSource, TResult>(this.Source.Count);
            RecordCurrentValues(this.Source);

            if (this.NotifyCollectionChangedMonitor.IsMonitoringChildProperties)
            {
                this.SourceIndex = new ListIndexer <TSource>(this.Source);
            }

            this.NotifyCollectionChangedMonitor.Add         += OnAdd;
            this.NotifyCollectionChangedMonitor.Remove      += OnRemove;
            this.NotifyCollectionChangedMonitor.Reset       += OnReset;
            this.NotifyCollectionChangedMonitor.Move        += OnMove;
            this.NotifyCollectionChangedMonitor.Replace     += OnReplace;
            this.NotifyCollectionChangedMonitor.ItemChanged += OnItemChanged;
        }
示例#5
0
 public static PropertyNotifier <T> Create <TResult>(Expression <Func <T, TResult> > expression)
 {
     return(new PropertyNotifier <T>(ExpressionPropertyAnalyzer.Analyze(expression)));
 }
 public static NotifyCollectionChangedMonitor <T> Create <TResult>(IList <T> input, Expression <Func <T, TResult> > expression)
 {
     return(new NotifyCollectionChangedMonitor <T>(ExpressionPropertyAnalyzer.Analyze(expression), input));
 }