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); }
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; }
public virtual async Task CallResumeAsync(ISuspensionAware viewmodel) { this.LogInfo(); if (viewmodel != null) { var suspensionState = GetSuspensionState(viewmodel); await viewmodel.OnResumingAsync(suspensionState); } }