Exemplo n.º 1
0
        protected void AddWeakEventListener(INotifyPropertyChanged _source, PropertyChangedEventHandler _handler)
        {
            if (null == _source)
            {
                throw new ArgumentNullException(nameof(_source));
            }
            if (null == _handler)
            {
                throw new ArgumentNullException(nameof(_handler));
            }

            var __listener = new PropertyChangedEventListener(_source, _handler);

            m_PropertyChangedListeners.Add(__listener);

            PropertyChangedEventManager.AddListener(_source, __listener, "");
        }
Exemplo n.º 2
0
        protected void RemoveWeakEventListener(INotifyPropertyChanged _source, PropertyChangedEventHandler _handler)
        {
            if (null == _source)
            {
                throw new ArgumentNullException(nameof(_source));
            }
            if (null == _handler)
            {
                throw new ArgumentNullException(nameof(_handler));
            }

            PropertyChangedEventListener __listener = m_PropertyChangedListeners.LastOrDefault(l => l.Source == _source && l.Handler == _handler);

            if (null != __listener)
            {
                m_PropertyChangedListeners.Remove(__listener);
                PropertyChangedEventManager.RemoveListener(_source, __listener, string.Empty);
            }
        }