public bool CanHandlePendingChanges([NotNull] Func <bool> hasPendingChanges, PendingChangesOption pendingChangeOptions) { try { _hasPendingChanges = hasPendingChanges(); if (!_hasPendingChanges) { return(true); } _canSave = false; if (!AutoSave) { return(CanHandle(pendingChangeOptions, out _canSave)); } _canSave = true; return(true); } catch (Exception e) { ErrorHandler.HandleError(e.Message, e, _msg, _owner); return(false); } }
private bool CanHandle(PendingChangesOption pendingChanges, out bool save) { save = false; bool canHandle; switch (pendingChanges) { case PendingChangesOption.SaveDiscardCancel: canHandle = ConfirmSaveDiscardCancelPendingChanges(out save); break; case PendingChangesOption.SaveCancel: canHandle = ConfirmSaveCancelPendingChanges(out save); break; case PendingChangesOption.SaveDiscard: canHandle = ConfirmSaveDiscardPendingChanges(out save); break; case PendingChangesOption.Save: save = true; canHandle = true; break; case PendingChangesOption.AssertNoPendingChanges: throw new InvalidOperationException( string.Format("Unexpected pending changes option: {0}", pendingChanges)); default: throw new InvalidOperationException( string.Format("Unknown pending changes option: {0}", pendingChanges)); } return(canHandle); }