/// <summary>
        /// Subscribes to the <see cref="INotifyPropertyChanged.PropertyChanged"/> event for a particular property.
        /// </summary>
        /// <param name="source">The object whose property is observed. May not be <c>null</c>.</param>
        /// <param name="propertyName">The name of the property to observe. May be <c>null</c> to indicate that all properties should be observed.</param>
        /// <param name="handler">The callback that is called when the property has changed. May not be <c>null</c>.</param>
        public PropertyChangedSubscription(INotifyPropertyChanged source, string propertyName, PropertyChangedEventHandler handler)
            : base(source)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }

            _threadAffinity = ThreadAffinity.BindToCurrentThread();
            _propertyName   = propertyName;
            _handler        = handler;

            _subscription           = SourceOnPropertyChanged;
            source.PropertyChanged += _subscription;
        }
Esempio n. 2
0
 /// <summary>
 /// Creates a new weak-event implementation of <c>ICommand.CanExecuteChanged</c>.
 /// </summary>
 /// <param name="sender">The sender of the <c>ICommand.CanExecuteChanged</c> event.</param>
 public WeakCanExecuteChanged(object sender)
 {
     _threadAffinity = ThreadAffinity.BindToCurrentThread();
     _sender         = sender;
 }
 private PropertyChangedNotificationManager()
 {
     _threadAffinity = ThreadAffinity.BindToCurrentThread();
 }
Esempio n. 4
0
 /// <summary>
 /// Creates a new explicit implementation of <c>ICommand.CanExecuteChanged</c>.
 /// </summary>
 /// <param name="sender">The sender of the <c>ICommand.CanExecuteChanged</c> event.</param>
 public ExplicitCanExecute(object sender)
 {
     _canExecuteChanged = new WeakCanExecuteChanged(sender);
     _threadAffinity    = ThreadAffinity.BindToCurrentThread();
 }