PWA Fundvelo der Caritas.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

PageHistoryManager.cs 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. namespace cwebplusApp.Shared.Services {
  4. public class PageHistoryManager {
  5. private readonly List<string> previousPages;
  6. public PageHistoryManager() {
  7. previousPages = new List<string>();
  8. }
  9. public void Reset() {
  10. previousPages.Clear();
  11. }
  12. public void AddPageToHistory(string pageName) {
  13. previousPages.Add(pageName);
  14. }
  15. public string GetPreviousPage() {
  16. if (CanGoBack()) {
  17. // You add a page on initialization, so you need to return the 2nd from the last
  18. string previousPage = previousPages.ElementAt(previousPages.Count - 2);
  19. previousPages.RemoveAt(previousPages.Count - 1);
  20. previousPages.RemoveAt(previousPages.Count - 1);
  21. return previousPage;
  22. }
  23. // Can't go back because you didn't navigate enough
  24. return previousPages.FirstOrDefault();
  25. }
  26. public bool CanGoBack() {
  27. return previousPages.Count > 1;
  28. }
  29. }
  30. }