public RootPlusHotelAndRestaurantSectionsNavigator(IInteractWithBrowserRouting historyHandler, AppDispatcher dispatcher) : base(Set <NonBlankTrimmedString> .Empty, historyHandler, dispatcher) { if (dispatcher == null) { throw new ArgumentNullException("dispatcher"); } AddRelativeRoute( Set <string> .Empty, new NavigateToRoot() ); _navigateToRoot = () => NavigateTo(); Hotels = new RootPlusDynamicIdItemPagesNavigator <Hotel>( Set.Of(new NonBlankTrimmedString("hotel")), historyHandler, dispatcher ); foreach (var route in Hotels.Routes) { AddRelativeRoute(route); } Restaurants = new RootPlusDynamicIdItemPagesNavigator <Restaurant>( Set.Of(new NonBlankTrimmedString("restaurant")), historyHandler, dispatcher ); foreach (var route in Restaurants.Routes) { AddRelativeRoute(route); } }
public NavigatorTestingDetails(TNavigator navigator, IInteractWithBrowserRouting historyHandler, IDispatcher dispatcher, Assert assert) { if (navigator == null) { throw new ArgumentNullException("navigator"); } if (historyHandler == null) { throw new ArgumentNullException("historyHandler"); } if (dispatcher == null) { throw new ArgumentNullException("dispatcher"); } if (assert == null) { throw new ArgumentNullException("assert"); } _receivedNavigationActions = NonNullList <INavigationDispatcherAction> .Empty; dispatcher.Receive(action => { var navigationDispatcherAction = action as INavigationDispatcherAction; if (navigationDispatcherAction != null) { _receivedNavigationActions = _receivedNavigationActions.Add(navigationDispatcherAction); } }); _historyHandler = historyHandler; _assert = assert; _actionsConfirmedSoFar = 0; Navigator = navigator; }
/// <summary> /// This method overload will optionally accept an action for cases where a route is found that can not be matched, if no routeNotMatched action is provided then invalid URLs will be ignored /// </summary> public static void StartListening(IInteractWithBrowserRouting historyHandler, NonNullList <IMatchRoutes> routes, Optional <Action <UrlPathDetails> > routeNotMatched = new Optional <Action <UrlPathDetails> >()) { if (historyHandler == null) { throw new ArgumentNullException(nameof(historyHandler)); } if (routes == null) { throw new ArgumentNullException(nameof(routes)); } historyHandler.RegisterForNavigatedCallback(url => MatchRoute(url, routes, routeNotMatched)); }
/// <summary> /// This method overload will execute the specified action if a URL is encountered that does not match any of the provided route (for cases where custom behaviour is desired, other than firing /// an InvalidRoute action at the dispatcher if an non-matching URL is found) /// </summary> public static void StartListening(IInteractWithBrowserRouting historyHandler, NonNullList <IMatchRoutes> routes, Action <UrlPathDetails> routeNotMatched) { if (historyHandler == null) { throw new ArgumentNullException(nameof(historyHandler)); } if (routes == null) { throw new ArgumentNullException(nameof(routes)); } if (routeNotMatched == null) { throw new ArgumentNullException(nameof(routeNotMatched)); } StartListening(historyHandler, routes, Optional.For(routeNotMatched)); }
/// <summary> /// This method overload will fire an InvalidRoute action to the specified dispatcher if a URL is encountered that does not match any of the provided route (this should be used in most cases since /// it means that all URLs result in a particular action being sent, whether the URL may be matched to a route or whether it was non-matched) /// </summary> public static void StartListening(IInteractWithBrowserRouting historyHandler, NonNullList <IMatchRoutes> routes, IDispatcher dispatcherForInvalidRouteActions) { if (historyHandler == null) { throw new ArgumentNullException(nameof(historyHandler)); } if (routes == null) { throw new ArgumentNullException(nameof(routes)); } if (dispatcherForInvalidRouteActions == null) { throw new ArgumentNullException(nameof(dispatcherForInvalidRouteActions)); } StartListening(historyHandler, routes, url => dispatcherForInvalidRouteActions.Dispatch(new InvalidRoute(url))); }
public RootPlusDynamicIdItemPagesNavigator(IInteractWithBrowserRouting historyHandler, AppDispatcher dispatcher) : this(Set <NonBlankTrimmedString> .Empty, historyHandler, dispatcher) { }
public RootPlusDynamicIdItemPagesNavigator(Set <NonBlankTrimmedString> parentSegments, IInteractWithBrowserRouting historyHandler, AppDispatcher dispatcher) : base(parentSegments, historyHandler, dispatcher) { if (dispatcher == null) { throw new ArgumentNullException("dispatcher"); } AddRelativeRoute( Set <string> .Empty, new NavigateToRoot <T>() ); _navigateToRoot = () => NavigateTo(); AddRelativeRoute( RouteBuilder.Empty.Fixed("item").String(), matchedValue => new NavigateToItem <T>(matchedValue.Item1) ); _navigateToItem = segment => NavigateTo("item", segment.Value); }