Exemple #1
0
 private void CheckWatcherWrapper()
 {
     if (_WatcherWrapper == null)
     {
         _WatcherWrapper = new BlockDictWatcher <IProperty>(this, OnPropertyChanged, OnPropertyChanged);
         AddDictWatcher(_WatcherWrapper);
     }
 }
        private IDictWatcher <T> GetWrapperWatcher(IDictWatcher watcher)
        {
            IDictWatcher <T> wrapper = null;

            if (_GenericWatcherMapping.TryGetValue(watcher, out wrapper))
            {
                return(wrapper);
            }
            return(null);
        }
        public bool RemoveDictWatcher <T1>(IDictWatcher <T1> watcher)
            where T1 : class, IInDictElement
        {
            IDictWatcher <T> wrapper = GetWrapperWatcher(watcher);;

            if (wrapper != null)
            {
                return(WeakListHelper.Remove(_GenericWatchers, wrapper));
            }
            return(false);
        }
        public bool AddDictWatcher <T1>(IDictWatcher <T1> watcher)
            where T1 : class, IInDictElement
        {
            IDictWatcher <T> wrapper = GetWrapperWatcher(watcher);;

            if (wrapper == null)
            {
                wrapper = CreateWrapperWatcher <T1>(watcher);
                return(WeakListHelper.Add(ref _GenericWatchers, wrapper));
            }
            return(false);
        }
        private IDictWatcher <T> CreateWrapperWatcher <T1>(IDictWatcher <T1> watcher)
            where T1 : class, IInDictElement
        {
            BlockDictWatcher <T> wrapper = new BlockDictWatcher <T>(this,
                                                                    (T _element) => {
                T1 element = _element as T1;
                if (element != null)
                {
                    watcher.OnElementAdded(element);
                }
            },
                                                                    (T _element) => {
                T1 element = _element as T1;
                if (element != null)
                {
                    watcher.OnElementAdded(element);
                }
            }
                                                                    );

            return(wrapper);
        }
 public bool RemoveDictWatcher(IDictWatcher <T> watcher)
 {
     return(WeakListHelper.Remove(_Watchers, watcher));
 }
 public bool AddDictWatcher(IDictWatcher <T> watcher)
 {
     return(WeakListHelper.Add(ref _Watchers, watcher));
 }