Пример #1
0
        private BeforeRouterResult Navigate(RouteContext to)
        {
            var routingEventArgs = new RoutingEventArgs(to, Route, _ViewModel);

            OnNavigating?.Invoke(this, routingEventArgs);

            if (routingEventArgs.Cancel)
            {
                _CurrentNavigations.Dequeue();
                to.Complete();
                return(BeforeRouterResult.Cancel());
            }

            var redirect = routingEventArgs.RedirectedTo;

            if (string.IsNullOrEmpty(redirect))
            {
                _ViewModel = to.ViewModel;
                return(BeforeRouterResult.Ok(_ViewModel));
            }

            to.Redirect(redirect, GetViewModelFromRoute(redirect));
            return(BeforeRouterResult.CreateRedirect(redirect));
        }
Пример #2
0
        private BeforeRouterResult BeforeResolve(string routeName)
        {
            var context = GetRouteContext(routeName);

            return((context == null) ? BeforeRouterResult.Cancel() : Navigate(context));
        }