Пример #1
0
 /// <summary>
 /// Notifies this object that a related <see cref="IPropertyStore"/> has changed.
 /// </summary>
 /// <param name="changed">Changed object instance.</param>
 /// <param name="change">Change details.</param>
 public virtual void NotifyChange(IPropertyStore changed, PropertyStoreChangeEventArgs change)
 {
     lock (SyncRoot)
     {
         // Suspend events
         SuspendEvents();
         try
         {
             // Notify subclass
             OnChangeNotification(changed, change);
         }
         finally
         {
             // Resume events
             ResumeEvents();
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Fires the <see cref="PropertyStoreChanged"/> and <see cref="PropertyChanged"/> events.
        /// </summary>
        protected virtual void OnPropertyChanged(PropertyStoreChangeEventArgs change)
        {
            // Validate
            if (change == null)
            {
                throw new ArgumentNullException(nameof(change));
            }

            // Fire events
            PropertyStoreChanged?.Invoke(this, change);
            if (PropertyChanged != null)
            {
                foreach (var propertyId in change.Keys)
                {
                    var propertyName = _propertyNames[propertyId];
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Called when events are resumed the last time, i.e. is not fired when nested. Fires the <see cref="PropertyStoreChanged"/> 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 PropertyStoreChangeEventArgs(_changedProperties.ToArray());

                    // Clear cache
                    _changedProperties.Clear();

                    // Fire events
                    OnPropertyChanged(args);
                }

                // Call base class method
                base.OnEventsResumed();
            }
        }
Пример #4
0
 /// <summary>
 /// Called when the <see cref="IPropertyStore.PropertyStoreChanged"/> event is fired on any of the <see cref="Children"/>.
 /// </summary>
 /// <param name="sender">Event initiator.</param>
 /// <param name="arguments">Event arguments.</param>
 /// <remarks>Inheritors must call this base class method first.</remarks>
 public virtual void OnChildPropertyChanged(object sender, PropertyStoreChangeEventArgs arguments)
 {
     // Currently empty but still required to call for future base code support
 }
Пример #5
0
 /// <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="EventCache.SuspendEvents"/> and <see cref="EventCache.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(IPropertyStore changed, PropertyStoreChangeEventArgs change)
 {
 }