Exemplo n.º 1
0
        /// <summary>
        /// Called when events are resumed the last time, i.e. is not fired when nested.
        /// Fires the <see cref="DataChanged"/> event when changes are pending.
        /// </summary>
        protected override void OnEventsResumed()
        {
            lock (SyncRoot)
            {
                // Fire pending DataChanged event
                if (_lastChangeAction.HasValue)
                {
                    // Build event
                    var properties = new List <Guid>(_committedPropertiesChanged);
                    foreach (var property in _instancePropertiesChanged)
                    {
                        if (!properties.Contains(property))
                        {
                            properties.Add(property);
                        }
                    }
                    var args = new DataObjectChangeEventArgs(_lastChangeAction.Value, properties.ToArray());

                    // Clear cache
                    _committedPropertiesChanged.Clear();
                    _instancePropertiesChanged.Clear();
                    _lastChangeAction = null;

                    // Fire event
                    if (DataChanged != null)
                    {
                        OnDataChanged(args);
                    }
                }

                // Call base class method
                base.OnEventsResumed();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Notifies this object that a related data object has changed.
 /// </summary>
 /// <param name="changed">Changed data object instance.</param>
 /// <param name="change">Change details.</param>
 public void NotifyChange(IDataObject changed, DataObjectChangeEventArgs change)
 {
     lock (SyncRoot)
     {
         // Suspend events
         SuspendEvents();
         try
         {
             // Notify subclass
             OnChangeNotification(changed, change);
         }
         finally
         {
             // Resume events
             ResumeEvents();
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Bubbles the <see cref="DataObject.DataChanged"/> event of an item in this collection.
 /// </summary>
 protected virtual void OnItemDataChanged(object sender, DataObjectChangeEventArgs e)
 {
     // Fire event
     ItemDataChanged?.Invoke(sender, e);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Handles change notification events, when this object is notified that
 /// a related data 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 data object instance.</param>
 /// <param name="change">Change details.</param>
 protected virtual void OnChangeNotification(IDataObject changed, DataObjectChangeEventArgs change)
 {
 }
Exemplo n.º 5
0
 /// <summary>
 /// Fires the <see cref="DataChanged"/> event.
 /// </summary>
 protected virtual void OnDataChanged(DataObjectChangeEventArgs change)
 {
     // Fire event
     DataChanged?.Invoke(this, change);
 }