示例#1
0
        private async Task ExecuteNavigationAction(PathResolution resolution)
        {
            var newFrames = (await FindNavigationFrames(resolution).ConfigureAwait(false)).ToList();

            if (newFrames.Count > 0) {
                PushCurrentFrameOntoStack();
            }

            foreach (var frame in newFrames) {
                // make frame the new active frame
                frame.Parent = _activeFrame;
                _activeFrame = frame;

                // activate the context
                await frame.Context.Activate().ConfigureAwait(false);
            }
        }
示例#2
0
        private async Task<IEnumerable<NavigationFrame>> FindNavigationFrames(PathResolution resolution)
        {
            var additionalFrames = new List<NavigationFrame>();

            // keep resolving for as long as we get new contexts
            while (resolution != null) {
                var context = await resolution.Execute().ConfigureAwait(false);
                if (context == null) {
                    break;
                }

                // add a new navigation frame to represent the context
                additionalFrames.Add(new NavigationFrame {
                    Context = context,
                    Path = resolution.MatchingPath
                });

                var excess = resolution.ExcessPath.LastOrDefault();
                if (excess != null) {
                    // only part of the path was handled, so ask the new context if it can handle the rest
                    resolution = context.HandleNavigation(excess);
                } else {
                    // the full path has been handled, so exit
                    break;
                }
            }

            return additionalFrames;
        }