Beispiel #1
0
        private async Task <Page> GetRootPage(Type viewmodelType)
        {
            if (_cachedRoots.TryGetValue(viewmodelType, out var cachedRootPage))
            {
                return(cachedRootPage);
            }

            var pageType = _registry.GetPageType(viewmodelType);

            Debug.Assert(pageType != null);

            var rootPage = _rootPageFactory.CreateRootPage(pageType);

            Debug.Assert(rootPage != null);

            _cachedRoots[viewmodelType] = rootPage;
            await InitializeRootPageViewmodel(rootPage);

            return(rootPage);
        }
Beispiel #2
0
        public async Task PushAsync(Type viewModelType, object parameter)
        {
            if (viewModelType == null)
            {
                throw new ArgumentNullException(nameof(viewModelType));
            }

            var pageType = _registry.GetPageType(viewModelType);

            Debug.Assert(pageType != null);

            var page = _pageFactory.CreatePage(pageType);

            Debug.Assert(page != null);

            var initializationTask = page.InitializeViewmodelAsync(parameter);
            var navigationTask     = InternalPushAsync(page);

            await Task.WhenAll(initializationTask, navigationTask);

            _logger.LogDebug($"Successfully pushed a page of type {pageType.Name}!");
        }