Пример #1
0
        internal static Uri Remove(Uri uri, bool implicitRoutes, bool defaultRoutes)
        {
            uri = ShellUriHandler.FormatUri(uri, null);

            string[] parts = uri.OriginalString.TrimEnd(_pathSeparator[0]).Split(_pathSeparator[0]);

            bool          userDefinedRouteAdded = false;
            List <string> toKeep = new List <string>();

            for (int i = 0; i < parts.Length; i++)
            {
                if (!(IsDefault(parts[i]) && defaultRoutes) && !(IsImplicit(parts[i]) && implicitRoutes))
                {
                    if (!String.IsNullOrWhiteSpace(parts[i]))
                    {
                        userDefinedRouteAdded = true;
                    }
                    toKeep.Add(parts[i]);
                }
            }

            if (!userDefinedRouteAdded && parts.Length > 0)
            {
                toKeep.Add(parts[parts.Length - 1]);
            }

            return(new Uri(string.Join(_pathSeparator, toKeep), UriKind.Relative));
        }
Пример #2
0
        internal static Uri RemoveImplicit(Uri uri)
        {
            uri = ShellUriHandler.FormatUri(uri);

            string[] parts = uri.OriginalString.TrimEnd(_pathSeparator[0]).Split(_pathSeparator[0]);

            List <string> toKeep = new List <string>();

            for (int i = 0; i < parts.Length; i++)
            {
                if (!IsImplicit(parts[i]))
                {
                    toKeep.Add(parts[i]);
                }
            }

            return(new Uri(string.Join(_pathSeparator, toKeep), UriKind.Relative));
        }
Пример #3
0
        internal static Uri Remove(Uri uri, bool implicitRoutes, bool defaultRoutes)
        {
            uri = ShellUriHandler.FormatUri(uri, null);

            string[] parts = uri.OriginalString.TrimEnd(_pathSeparator[0]).Split(_pathSeparator[0]);

            bool          userDefinedRouteAdded = false;
            List <string> toKeep = new List <string>();

            for (int i = 0; i < parts.Length; i++)
            {
                // This means there are no routes defined on the shell but the user has navigated to a global route
                // so we need to attach the final route where the user left the shell
                if (s_routes.ContainsKey(parts[i]) && !userDefinedRouteAdded && i > 0)
                {
                    toKeep.Add(parts[i - 1]);
                }

                if (!(IsDefault(parts[i]) && defaultRoutes) && !(IsImplicit(parts[i]) && implicitRoutes))
                {
                    if (!String.IsNullOrWhiteSpace(parts[i]))
                    {
                        userDefinedRouteAdded = true;
                    }

                    toKeep.Add(parts[i]);
                }
            }

            if (!userDefinedRouteAdded && parts.Length > 0)
            {
                toKeep.Add(parts[parts.Length - 1]);
            }

            return(new Uri(string.Join(_pathSeparator, toKeep), UriKind.Relative));
        }