/// <summary> /// Discards changes since the last <see cref="IEditableObject.BeginEdit()"/> call. /// </summary> void IEditableObject.CancelEdit() { if (_backup == null) { Log.Debug("IEditableObject is not in edit state"); return; } CancelEditCompletedEventArgs cancelEditCompletedEventArgs; var eventArgs = new CancelEditEventArgs(this); _cancelEditingEvent.SafeInvoke(this, eventArgs); OnCancelEdit(eventArgs); if (eventArgs.Cancel) { Log.Info("IEditableObject.CancelEdit is canceled by the event args"); cancelEditCompletedEventArgs = new CancelEditCompletedEventArgs(true); _cancelEditingCompletedEvent.SafeInvoke(this, cancelEditCompletedEventArgs); OnCancelEditCompleted(cancelEditCompletedEventArgs); return; } Log.Debug("IEditableObject.CancelEdit"); _backup.RestoreBackup(); _backup = null; cancelEditCompletedEventArgs = new CancelEditCompletedEventArgs(false); _cancelEditingCompletedEvent.SafeInvoke(this, cancelEditCompletedEventArgs); OnCancelEditCompleted(cancelEditCompletedEventArgs); }
/// <summary> /// Discards changes since the last <see cref="IEditableObject.BeginEdit()"/> call. /// </summary> void IEditableObject.CancelEdit() { if (_backup == null) { return; } var eventArgs = new CancelEditEventArgs(this); _cancelEditingEvent.SafeInvoke(this, eventArgs); OnCancelEdit(eventArgs); if (eventArgs.Cancel) { Log.Info("IEditableObject.CancelEdit is canceled by the event args"); return; } Log.Debug("IEditableObject.CancelEdit"); _backup.RestoreBackup(); _backup = null; }