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);
            }
        }
예제 #2
0
        public RootPlusHotelAndRestaurantSectionsNavigator(IDispatcher dispatcher) : base(NonNullList <NonBlankTrimmedString> .Empty, dispatcher)
        {
            if (dispatcher == null)
            {
                throw new ArgumentNullException("dispatcher");
            }

            // This is the only route that this class directly creates..
            _getRoot = AddRelativeRoute(
                segments: NonNullList <string> .Empty,
                routeAction: new NavigateToRoot(),
                urlGenerator: () => GetPath()
                );

            // .. however it does also create some other navigators that will declare routes under the "hotel" section and the "restaurant" section
            // (and we'll need to add the routes that these navigators declare to this instance's total set of known routes()
            PullInRoutesFrom(Hotels = new RootPlusDynamicIdItemPagesNavigator <Hotel>(
                                 parentSegments: NonNullList.Of(new NonBlankTrimmedString("hotel")),
                                 dispatcher: dispatcher
                                 ));
            PullInRoutesFrom(Restaurants = new RootPlusDynamicIdItemPagesNavigator <Restaurant>(
                                 parentSegments: NonNullList.Of(new NonBlankTrimmedString("restaurant")),
                                 dispatcher: dispatcher
                                 ));
        }