Exemplo n.º 1
0
        public NavigationUrl Build(Action <NavigationUrlQuery> updateQuery = null)
        {
            var newQuery = new NavigationUrlQuery(url.Segments.Last().Query);
            var segments = new List <NavigationUrlSegment>();

            for (int i = 0; i < this.url.Segments.Count(); i++)
            {
                var segment = this.url.Segments[i];
                if (i == this.url.Segments.Length - 1)
                {
                    segment = new NavigationUrlSegment(segment.Value, newQuery);
                }
                else
                {
                    segment = new NavigationUrlSegment(segment.Value);
                }

                segments.Add(segment);
            }

            updateQuery?.Invoke(newQuery);
            var newUrl = new NavigationUrl(segments.ToArray());

            return(newUrl);
        }
Exemplo n.º 2
0
        public void Navigate <T>(Action <NavigationUrlSegment> prepareQuery, NavigationDirection direction = NavigationDirection.Forward)
        {
            var segment = new NavigationUrlSegment(typeof(T).FullName);

            prepareQuery(segment);
            this.Navigate(new NavigationUrl(new [] { segment }), direction);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds the argument to the query of the last segment.
        /// </summary>
        /// <param name="name">Name.</param>
        /// <param name="value">Value.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        public NavigationUrl AddArg <T>(string name, T value)
        {
            var segment = this.Segments.LastOrDefault();

            if (segment == null)
            {
                segment       = new NavigationUrlSegment("");
                this.Segments = new[] { segment };
            }

            segment.AddArg(name, value);

            return(this);
        }