public NavigationRequest(RequestDefinition definition, WhatToDoWithTheStack stackRequest, string query, string fragment) { StackRequest = stackRequest; Query = query; Fragment = fragment; Request = definition; }
public static NavigationRequest GetNavigationRequest(Shell shell, Uri uri) { uri = FormatUri(uri); // figure out the intent of the Uri NavigationRequest.WhatToDoWithTheStack whatDoIDo = NavigationRequest.WhatToDoWithTheStack.PushToIt; if (uri.IsAbsoluteUri) { whatDoIDo = NavigationRequest.WhatToDoWithTheStack.ReplaceIt; } else if (uri.OriginalString.StartsWith("//") || uri.OriginalString.StartsWith("\\\\")) { whatDoIDo = NavigationRequest.WhatToDoWithTheStack.ReplaceIt; } else { whatDoIDo = NavigationRequest.WhatToDoWithTheStack.PushToIt; } Uri request = ConvertToStandardFormat(shell, uri); var possibleRouteMatches = GenerateRoutePaths(shell, request, uri); if (possibleRouteMatches.Count == 0) { throw new ArgumentException($"unable to figure out route for: {uri}", nameof(uri)); } else if (possibleRouteMatches.Count > 1) { string[] matches = new string[possibleRouteMatches.Count]; int i = 0; foreach (var match in possibleRouteMatches) { matches[i] = match.PathFull; i++; } string matchesFound = String.Join(",", matches); throw new ArgumentException($"Ambiguous routes matched for: {uri} matches found: {matchesFound}", nameof(uri)); } var theWinningRoute = possibleRouteMatches[0]; RequestDefinition definition = new RequestDefinition( ConvertToStandardFormat(shell, new Uri(theWinningRoute.PathFull, UriKind.RelativeOrAbsolute)), new Uri(theWinningRoute.PathNoImplicit, UriKind.RelativeOrAbsolute), theWinningRoute.Item, theWinningRoute.Section, theWinningRoute.Content, theWinningRoute.GlobalRouteMatches); NavigationRequest navigationRequest = new NavigationRequest(definition, whatDoIDo, request.Query, request.Fragment); return(navigationRequest); }
internal static NavigationRequest GetNavigationRequest(Shell shell, Uri uri, bool enableRelativeShellRoutes = false, bool throwNavigationErrorAsException = true, ShellNavigationParameters shellNavigationParameters = null) { uri = FormatUri(uri, shell); // figure out the intent of the Uri NavigationRequest.WhatToDoWithTheStack whatDoIDo = CalculateStackRequest(uri); Uri request = ConvertToStandardFormat(shell, uri); var possibleRouteMatches = GenerateRoutePaths(shell, request, uri, enableRelativeShellRoutes); if (possibleRouteMatches.Count == 0) { if (throwNavigationErrorAsException) { throw new ArgumentException($"unable to figure out route for: {uri}", nameof(uri)); } return(null); } else if (possibleRouteMatches.Count > 1) { string[] matches = new string[possibleRouteMatches.Count]; int i = 0; foreach (var match in possibleRouteMatches) { matches[i] = match.PathFull; i++; } string matchesFound = String.Join(",", matches); if (throwNavigationErrorAsException) { throw new ArgumentException($"Ambiguous routes matched for: {uri} matches found: {matchesFound}", nameof(uri)); } return(null); } var theWinningRoute = possibleRouteMatches[0]; RequestDefinition definition = new RequestDefinition(theWinningRoute, shell); NavigationRequest navigationRequest = new NavigationRequest(definition, whatDoIDo, request.Query, request.Fragment); return(navigationRequest); }