private PropertyWatcherList <T> SetupPropertyWatcher() { if (_propertiesToWatch != null) { var watcherList = new PropertyWatcherList <T>(_propertiesToWatch); watcherList.ValueChanged += (i, v) => ItemModified?.Invoke(this, i, v); return(watcherList); } return(null); }
public CollectionWrapper(IReadOnlyList <T> collection, string[] propertiesToWatch = null) { if ((propertiesToWatch?.Length ?? 0) > 0) { _propertiesToWatch = propertiesToWatch; } _watcherList = SetupPropertyWatcher(); ReplaceCollection(collection); }
public void Dispose() { if (_isDisposed) { return; } _isDisposed = true; if (_collection is INotifyCollectionChanged) { CollectionChangedEventManager.RemoveHandler(_collection as INotifyCollectionChanged, HandleCollectionChange); _watcherList?.Dispose(); _watcherList = null; _collection = null; ItemModified = null; } }