private bool CanClose <TViewModel>(TViewModel viewModel, [NotNullWhen(true)] out IStackAlgorithm stackAlgorithm) where TViewModel : ViewModelBase { var mainParent = GetMainParentFor(viewModel); if (TryGetStackAlgorithmFor(mainParent, out stackAlgorithm, out var stack, out var index)) { return(stack.Count - 1 == index); } return(false); }
private bool TryGetStackAlgorithmFor <TViewModel>(TViewModel viewModel, [NotNullWhen(true)] out IStackAlgorithm stackAlgorithm, out IReadOnlyList <ViewModelBase> stack, out int index) where TViewModel : ViewModelBase { foreach (var(_, value) in _stackAlgorithms) { if (value.TryGetFromStack(viewModel, out stack, out index)) { stackAlgorithm = value; return(true); } } stackAlgorithm = null; stack = new List <ViewModelBase>(); index = -1; return(false); }
private async Task ClosePrivateAsync <TResult>( IStackAlgorithm stackAlgorithm, Action <TResult, CancelEventArgs> viewClosing, Action <TResult> viewClosed, TResult result, bool withAnimation = true) { await ExecuteInNavigateSafelyAsync(async() => { var args = new CancelEventArgs(); viewClosing?.Invoke(result, args); if (args.Cancel) { return; } await stackAlgorithm.CloseAsync(withAnimation); viewClosed?.Invoke(result); }); }