Example #1
0
        private void CloneSourceList(ReferenceCountTracker <T> tracker, IChangeSet <T> changes)
        {
            changes.ForEach(change =>
            {
                switch (change.Reason)
                {
                case ListChangeReason.Add:
                    tracker.Add(change.Item.Current);
                    break;

                case ListChangeReason.AddRange:
                    foreach (var t in change.Range)
                    {
                        tracker.Add(t);
                    }
                    break;

                case ListChangeReason.Replace:
                    tracker.Remove(change.Item.Previous.Value);
                    tracker.Add(change.Item.Current);
                    break;

                case ListChangeReason.Remove:
                    tracker.Remove(change.Item.Current);
                    break;

                case ListChangeReason.RemoveRange:
                case ListChangeReason.Clear:
                    foreach (var t in change.Range)
                    {
                        tracker.Remove(t);
                    }
                    break;
                    //case ListChangeReason.Clear:
                    //    tracker.Clear();
                    //    break;
                }
            });
        }
Example #2
0
 protected override void RemoveItem(int index, T item)
 {
     _tracker.Remove(item);
     base.RemoveItem(index, item);
 }