/// <summary> /// Notifies this object that a related <see cref="IPropertyObject"/> has changed. /// </summary> /// <param name="changed">Changed object instance.</param> /// <param name="change">Change details.</param> public virtual void NotifyChange(IPropertyObject changed, PropertyObjectChangeEventArgs change) { lock (SyncRoot) { // Suspend events SuspendEvents(); try { // Notify subclass OnChangeNotification(changed, change); } finally { // Resume events ResumeEvents(); } } }
/// <summary> /// Called when events are resumed the last time, i.e. is not fired when nested. /// Fires the <see cref="PropertyObjectChanged"/> event when changes are pending. /// </summary> protected override void OnEventsResumed() { lock (SyncRoot) { // Fire pending PropertyChanged event if (_changedProperties.Count > 0) { // Build event var args = new PropertyObjectChangeEventArgs(_changedProperties.ToArray()); // Clear cache _changedProperties.Clear(); // Fire events OnPropertyChanged(args); } // Call base class method base.OnEventsResumed(); } }
/// <summary> /// Fires the <see cref="PropertyObjectChanged"/> and <see cref="PropertyChanged"/> events. /// </summary> protected virtual void OnPropertyChanged(PropertyObjectChangeEventArgs change) { // Validate if (change == null) { throw new ArgumentNullException("change"); } // Fire events if (PropertyObjectChanged != null) { PropertyObjectChanged(this, change); } if (PropertyChanged != null) { foreach (var propertyId in change.Keys) { var propertyName = _propertyNames[propertyId]; PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } }
public virtual void OnChildPropertyChanged(object sender, PropertyObjectChangeEventArgs arguments) { // Currently empty but still required to call for future base code support }
/// <summary> /// Handles change notification events, when this object is notified that /// a related view object has changed via the <see cref="NotifyChange"/> method. /// </summary> /// <remarks> /// Thread safe locking, <see cref="EventObject.SuspendEvents"/> and <see cref="EventObject.ResumeEvents"/> are handled by the caller. /// The base class implementation does nothing. /// </remarks> /// <param name="changed">Changed view object instance.</param> /// <param name="change">Change details.</param> protected virtual void OnChangeNotification(IPropertyObject changed, PropertyObjectChangeEventArgs change) { }