/// <summary>
        ///     コンストラクタ
        /// </summary>
        /// <param name="source">INotifyPropertyChangedオブジェクト</param>
        public PropertyChangedEventListener([NotNull] INotifyPropertyChanged source)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            _bag = new AnonymousPropertyChangedEventHandlerBag(source);
            Initialize(
                h => source.PropertyChanged += h,
                h => source.PropertyChanged -= h,
                (sender, e) => _bag.ExecuteHandler(e ?? throw new ArgumentNullException(nameof(e))));
        }
Exemple #2
0
 /// <summary>
 /// コンストラクタ。リスナのインスタンスの作成と同時にハンドラを一つ登録します。
 /// </summary>
 /// <param name="source">INotifyPropertyChangedオブジェクト</param>
 /// <param name="handler">PropertyChangedイベントハンドラ</param>
 public PropertyChangedEventListener(INotifyPropertyChanged source, PropertyChangedEventHandler handler)
 {
     _bag = new AnonymousPropertyChangedEventHandlerBag(source, handler);
     Initialize(h => source.PropertyChanged += h, h => source.PropertyChanged -= h, (sender, e) => _bag.ExecuteHandler(e));
 }