Пример #1
0
        protected ISuspensionState GetSuspensionState(ISuspensionAware viewmodel)
        {
            var rootContainer = ApplicationData.Current.LocalSettings;
            var key           = $"{viewmodel.GetType()}";
            var values        = rootContainer.CreateContainer(key, ApplicationDataCreateDisposition.Existing).Values as ISuspensionState;

            if (values.ContainsKey(key))
            {
                DateTime age;
                if (DateTime.TryParse(values[key]?.ToString(), out age))
                {
                    var setting = App.Settings.SuspensionStateExpires;
                    var expires = DateTime.Now.Subtract(setting);
                    var expired = expires <= age;
                    if (expired)
                    {
                        values.Clear();
                        TimeStamp(values);
                    }
                    else
                    {
                        // happiness
                    }
                }
                else
                {
                    TimeStamp(values);
                }
            }
            else
            {
                TimeStamp(values);
            }
            return(values);
        }
Пример #2
0
 protected ISuspensionState GetSuspensionState(ISuspensionAware viewmodel)
 {
     var rootContainer = ApplicationData.Current.LocalSettings;
     var key = $"{viewmodel.GetType()}";
     var values = rootContainer.CreateContainer(key, ApplicationDataCreateDisposition.Existing).Values as ISuspensionState;
     if (values.ContainsKey(key))
     {
         DateTime age;
         if (DateTime.TryParse(values[key]?.ToString(), out age))
         {
             var setting = App.Settings.SuspensionStateExpires;
             var expires = DateTime.Now.Subtract(setting);
             var expired = expires <= age;
             if (expired)
             {
                 values.Clear();
                 TimeStamp(values);
             }
             else
             {
                 // happiness
             }
         }
         else
         {
             TimeStamp(values);
         }
     }
     else
     {
         TimeStamp(values);
     }
     return values;
 }
Пример #3
0
        public virtual async Task CallResumeAsync(ISuspensionAware viewmodel)
        {
            this.LogInfo();

            if (viewmodel != null)
            {
                var suspensionState = GetSuspensionState(viewmodel);
                await viewmodel.OnResumingAsync(suspensionState);
            }
        }
Пример #4
0
        public virtual async Task CallResumeAsync(ISuspensionAware viewmodel)
        {
            this.LogInfo();

            if (viewmodel != null)
            {
                var suspensionState = GetSuspensionState(viewmodel);
                await viewmodel.OnResumingAsync(suspensionState);
            }
        }