/// <inheritdoc /> public async Task <TResult> NavigateAsync <TResult>( IWavesViewModel <TResult> viewModel, bool addToHistory = true) { try { var view = await _core.GetInstanceAsync <IWavesView>(viewModel.GetType()); switch (view) { case IWavesWindow <TContent> window: return(await NavigateToWindowAsync(window, viewModel)); case IWavesUserControl <TContent> userControl: return(await NavigateToUserControlAsync(userControl, viewModel, addToHistory)); case IWavesPage <TContent> page: return(await NavigateToPageAsync(page, viewModel, addToHistory)); case IWavesDialog <TContent> dialog: return(await NavigateToDialogAsync(dialog, (IWavesDialogViewModel <TResult>) viewModel, addToHistory)); } } catch (Exception e) { Logger.LogError(e, "An error occured while navigating"); } return(default);
/// <inheritdoc /> public async Task NavigateAsync(IWavesViewModel viewModel, bool addToHistory = true) { try { var view = await _core.GetInstanceAsync <IWavesView>(viewModel.GetType()); switch (view) { case IWavesWindow <TContent> window: await InitializeWindowAsync(window, viewModel); break; case IWavesUserControl <TContent> userControl: await InitializeUserControlAsync(userControl, viewModel, addToHistory); break; case IWavesPage <TContent> page: await InitializePageAsync(page, viewModel, addToHistory); break; case IWavesDialog <TContent> dialog: await InitializeDialogAsync(dialog, (IWavesDialogViewModel)viewModel, addToHistory); break; } } catch (Exception e) { Logger.LogError(e, "An error occured while navigating"); } }
/// <inheritdoc /> public async Task GoBackAsync(IWavesViewModel viewModel) { foreach (var history in Histories .Select(pair => pair.Value) .Where(history => Enumerable.Contains(history, viewModel))) { if (history.Count <= 1) { return; } var removingViewModel = history.Pop(); if (removingViewModel is IWavesDialogViewModel removingDialogViewModel) { DialogSessions.Remove(removingDialogViewModel); } NotifyDialogEvents(); await NavigateAsync(history.First(), false); return; } }