private async Task <RouterState> GetRouterState(IObjectStateStore stateStore) { ObjectState existingState = null; try { existingState = await stateStore.LoadStateAsync(); } catch (Exception e) { this.Log().WarnException("Could not load state from state store.", e); await InvalidateStateAsync(stateStore); } RouterState routerState = null; try { routerState = (RouterState)existingState?.State; } catch (InvalidCastException e) { this.Log().WarnException($"Could not cast loaded state to {nameof(RouterState)}. Was a breaking change made to the app's stored data model?", e); await InvalidateStateAsync(stateStore); } return(routerState); }
private async Task ResumeRouterAsync(IRouter router, RouterConfig routerConfig, RouterState routerState, IObjectStateStore stateStore) { await ActivationHelpers.InitObjectAsync(router, routerConfig); try { if (routerState != null) { await ActivationHelpers.ResumeObjectStateAsync(router, routerState); } } catch (Exception e) { this.Log().WarnException("Could not resume the router state.", e); await InvalidateStateAsync(stateStore); } }