示例#1
0
        private async Task <INavigationResult> NavigateAsync(
            NavigationQueue queue,
            NavigationTransitionInfo infoOverride)
        {
            _logger.Log($"{nameof(FrameFacade)}.{nameof(NavigateAsync)}({queue})", Category.Info, Priority.None);

            // clear stack, if requested

            if (queue.ClearBackStack)
            {
                _frame.SetNavigationState(new Frame().GetNavigationState());
            }

            // iterate through queue

            while (queue.Count > 0)
            {
                var pageNavinfo = queue.Dequeue();

                var result = await NavigateAsync(
                    pageNavInfo : pageNavinfo,
                    infoOverride : infoOverride);

                // do not continue on failure

                if (!result.Success)
                {
                    return(result);
                }
            }

            // finally

            return(this.NavigationSuccess());
        }
示例#2
0
 public async Task <INavigationResult> NavigateAsync(
     Uri path,
     INavigationParameters parameter,
     NavigationTransitionInfo infoOverride)
 {
     return(await NavigateAsync(
                queue : NavigationQueue.Parse(path, parameter),
                infoOverride : infoOverride));
 }
示例#3
0
        public static bool TryParse(string path, INavigationParameters parameters, out NavigationQueue queue)
        {
            if (string.IsNullOrEmpty(path))
            {
                queue = null;
                return(false);
            }

            if (Uri.TryCreate(path, UriKind.RelativeOrAbsolute, out var uri))
            {
                return(TryParse(new Uri(path, UriKind.Relative), parameters, out queue));
            }
            else
            {
                queue = null;
                return(false);
            }
        }
示例#4
0
        public static bool TryParse(Uri uri, INavigationParameters parameters, out NavigationQueue queue)
        {
            if (uri == null)
            {
                queue = null;
                return(false);
            }

            if (uri.IsAbsoluteUri)
            {
                throw new Exception("Navigation path must not be absolute Uri.");
            }

            var groups = uri.OriginalString.Split('/')
                         .Where(x => !string.IsNullOrEmpty(x))
                         .Select((path, index) => new NavigationPath(index, path, parameters));

            queue = new NavigationQueue(groups)
            {
                ClearBackStack = uri.OriginalString.StartsWith("/"),
            };

            return(queue.Any());
        }