Catel.MVVM.Providers.UserControlLogic.OnParentViewModelCancelingAsync C# (CSharp) Method

OnParentViewModelCancelingAsync() private method

Handles the Canceling event of the parent ViewModel.
private OnParentViewModelCancelingAsync ( object sender, CancelingEventArgs e ) : Task
sender object The source of the event.
e CancelingEventArgs The instance containing the event data.
return Task
        private async Task OnParentViewModelCancelingAsync(object sender, CancelingEventArgs e)
        {
            // The parent view model is canceled, cancel our view model as well
            if (ViewModel != null)
            {
                if (ReferenceEquals(sender, ViewModel))
                {
                    Log.Warning("Parent view model '{0}' is exactly the same instance as the current view model, ignore Canceling event", sender.GetType().FullName);
                    return;
                }

                if (e.Cancel)
                {
                    Log.Info("Parent view model '{0}' is canceling, but canceling is canceled by another view model, canceling of view model '{1}' will not continue", _parentViewModel.GetType(), ViewModel.GetType());
                    return;
                }

                Log.Info("Parent view model '{0}' is canceled, cancelling view model '{1}' as well", _parentViewModel.GetType(), ViewModel.GetType());

                if (!ViewModel.IsClosed)
                {
                    e.Cancel = !await ViewModel.CancelViewModelAsync();
                }
            }
        }