Пример #1
0
 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);
 }
Пример #2
0
        public CollectionWrapper(IReadOnlyList <T> collection, string[] propertiesToWatch = null)
        {
            if ((propertiesToWatch?.Length ?? 0) > 0)
            {
                _propertiesToWatch = propertiesToWatch;
            }

            _watcherList = SetupPropertyWatcher();

            ReplaceCollection(collection);
        }
Пример #3
0
        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;
            }
        }