예제 #1
0
        /// <summary>
        /// Resets the collection by reevaluating the groupings.
        /// </summary>
        void Reset()
        {
            // find new and old items
            var nowItems = groups.Values.SelectMany(i => i);
            var newItems = Lambdas.Select(i => Lambdas[i]).Except(nowItems).ToList();
            var oldItems = nowItems.Except(newItems).ToList();

            // remove old items
            foreach (var item in oldItems)
            {
                RemoveItem(item);
            }

            // add new items
            foreach (var item in newItems)
            {
                AddItem(item);
            }
        }
예제 #2
0
        protected override void OnLambdaCollectionReset()
        {
            // unsubscribe from all items
            foreach (var item in items)
            {
                UnsubscribeItem(item);
            }

            // reset all items
            items.Clear();
            items.AddRange(Lambdas.Select(i => i.Value));

            // subscribe to all items
            foreach (var item in items)
            {
                SubscribeItem(item);
            }

            OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
        }
예제 #3
0
 public IEnumerator <TResult> GetEnumerator()
 {
     return(Lambdas.Select(i => i.Value).GetEnumerator());
 }