public NotifyCollectionChangedMonitor(PropertyAccessTree propertyAccessTree, IList <T> input) { if (input == null) { throw new ArgumentNullException("input"); } INotifyCollectionChanged inputAsINotifyCollectionChanged = input as INotifyCollectionChanged; if (inputAsINotifyCollectionChanged == null) { throw new ArgumentException("Collections must implement INotifyCollectionChanged to work with CLINQ"); } _input = input; this.PropertyAccessTree = propertyAccessTree; this.ReferenceCountTracker = new ReferenceCountTracker <T>(); SetupPropertyChangeSubscription(); SubscribeToItems(_input); WeakNotifyCollectionChangedEventHandler.Register( inputAsINotifyCollectionChanged, this, (me, sender, args) => me.OnCollectionChanged(sender, args)); }
public CollectionMonitor(IList <T> input) { if (input == null) { throw new ArgumentNullException("input"); } INotifyCollectionChanged inputAsINotifyCollectionChanged = input as INotifyCollectionChanged; if (inputAsINotifyCollectionChanged == null) { throw new ArgumentException("Collections must implement INotifyCollectionChanged."); } _input = input; _Properties = new List <PropertyNotifier <T> >(); Properties = new ReadOnlyCollection <PropertyNotifier <T> >(_Properties); ReferenceCountTracker = new ReferenceCountTracker <T>(); WeakNotifyCollectionChangedEventHandler.Register( inputAsINotifyCollectionChanged, this, (me, sender, args) => me.OnCollectionChanged(args)); // Add Items to Reference Counter foreach (var item in input) { ReferenceCountTracker.Add(item); } }