Esempio n. 1
0
        public async Task SaveAsync()
        {
            // save navigation state into settings

            DebugWrite($"Frame: {FrameFacade.FrameId}");

            if (CurrentPageType == null)
            {
                return;
            }
            if (RaiseBeforeSavingNavigation())
            {
                return;
            }

            var frameState = Suspension.GetFrameState();

            if (frameState == null)
            {
                throw new InvalidOperationException("State container is unexpectedly null");
            }

            frameState.Write <string>("CurrentPageType", CurrentPageType.AssemblyQualifiedName);
            frameState.Write <object>("CurrentPageParam", CurrentPageParam);
            frameState.Write <string>("NavigateState", FrameFacade.GetNavigationState());

            await Task.CompletedTask;
        }
Esempio n. 2
0
        public void SaveNavigation()
        {
            DebugWrite($"Frame: {FrameFacade.FrameId}");

            if (CurrentPageType == null)
            {
                return;
            }
            var args = new CancelEventArgs <Type>(FrameFacade.CurrentPageType);

            BeforeSavingNavigation?.Invoke(this, args);
            if (args.Cancel)
            {
                return;
            }

            var state = FrameFacade.PageStateSettingsService(GetType());

            if (state == null)
            {
                throw new InvalidOperationException("State container is unexpectedly null");
            }

            state.Write <string>("CurrentPageType", CurrentPageType.AssemblyQualifiedName);
            state.Write <object>("CurrentPageParam", CurrentPageParam);
            state.Write <string>("NavigateState", FrameFacade?.GetNavigationState());
        }
Esempio n. 3
0
        public void SaveNavigation()
        {
            if (CurrentPageType == null)
            {
                return;
            }
            var args = new CancelEventArgs <Type>(FrameFacade.CurrentPageType);

            BeforeSavingNavigation?.Invoke(this, args);
            if (args.Cancel)
            {
                return;
            }

            var state = FrameFacade.PageStateContainer(GetType());

            if (state == null)
            {
                throw new InvalidOperationException("State container is unexpectedly null");
            }

            state["CurrentPageType"]  = CurrentPageType.AssemblyQualifiedName;
            state["CurrentPageParam"] = ParameterSerializationService.Instance.SerializeParameter(CurrentPageParam);
            state["NavigateState"]    = FrameFacade?.GetNavigationState();
        }
Esempio n. 4
0
        public void SaveNavigation()
        {
            var state = State(GetType());

            state["CurrentPageType"]  = CurrentPageType.ToString();
            state["CurrentPageParam"] = CurrentPageParam;
            state["NavigateState"]    = _frame.GetNavigationState();
        }
Esempio n. 5
0
 public async Task <bool> RefreshAsync()
 {
     return(await NavigationOrchestratorAsync(CurrentPageType, CurrentPageParam, NavigationMode.Refresh, () =>
     {
         Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().Reset();
         FrameFacade.SetNavigationState(FrameFacade.GetNavigationState());
         return true;
     }));
 }
Esempio n. 6
0
        public void SaveNavigation()
        {
            var state = FrameFacade.PageStateContainer(GetType());

            if (state == null)
            {
                throw new InvalidOperationException("State container is unexpectedly null");
            }

            state["CurrentPageType"]  = CurrentPageType?.ToString();
            state["CurrentPageParam"] = CurrentPageParam;
            state["NavigateState"]    = FrameFacade?.GetNavigationState();
        }
Esempio n. 7
0
        public void SaveNavigation()
        {
            var state = FrameFacade.PageStateContainer(GetType());

            if (state == null)
            {
                throw new InvalidOperationException("State container is unexpectedly null");
            }

            state["CurrentPageType"] = CurrentPageType.ToString();
            try { state["CurrentPageParam"] = CurrentPageParam; }
            catch
            {
                throw new Exception("Failed to serialize page parameter, override/implement ToString()");
            }
            state["NavigateState"] = FrameFacade?.GetNavigationState();
        }
Esempio n. 8
0
 public async Task <bool> RefreshAsync(object param)
 {
     return(await NavigationOrchestratorAsync(CurrentPageType, param, NavigationMode.Refresh, () =>
     {
         try
         {
             Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().Reset();
             FrameFacade.SetNavigationState(FrameFacade.GetNavigationState());
             return true;
         }
         catch (Exception ex)
         {
             // Catch and ignore exceptions
             DebugWrite(ex.Message, Severities.Error);
             return false;
         }
     }));
 }