protected override void AfterSetup()
        {
            Window.Content = Frame = new ContentControl();

            var controllerFactory = new ControllerFactory();
            controllerFactory.Register("Sample", () => new SampleController() { ActionInvoker = new DefaultActionInvoker() });

            var routes = new ControllerRouteCatalog(controllerFactory);
            routes.MapRoute("foobar/{action}", new {controller = "Sample"});

            NavigatorFactory = new NavigatorFactory(routes);
            Navigator = NavigatorFactory.CreateNavigator(Frame);
        }
Exemple #2
0
        private void ApplicationStartup(object sender, StartupEventArgs e)
        {
            var main = new MainView();
            RootVisual = main;

            var controllerFactory = new ControllerFactory();
            controllerFactory.Register("Home", () => new HomeController());

            var routes = new RouteCollection();
            routes.Register("Patient", "Patients/{patientId}", new ControllerRouteHandler(controllerFactory)).Defaults(controller => "Home", action => "Patient");
            routes.Register("Default", "{controller}/{action}", new ControllerRouteHandler(controllerFactory));

            var navigator = new Navigator(routes);
            navigator.RegisterFrame(main.MainFrame);
            navigator.Navigate(controller => "Home", action => "Index");
        }
        public void NavigateToRouteResolvesRightController()
        {
            var controller1 = new Mock<IController>();
            var controller2 = new Mock<IController>();
            var controllers = new ControllerFactory();
            controllers.Register("C1", () => controller1.Object);
            controllers.Register("C2", () => controller2.Object);
            var routes = new ControllerRouteCatalog(controllers);
            routes.MapRoute("search/{action}", new { controller = "C1" });
            routes.MapRoute("patients/{action}", new { controller = "C2" });

			var navigator = new Navigator(Factory.Object, null, "magellan", new RouteResolver(routes), () => NavigationService.Object);

            navigator.Navigate(new { controller = "C2", action = "foo" });
            controller2.Verify(x => x.Execute(It.IsAny<ControllerContext>()));

            navigator.Navigate(new { controller = "C1", action = "foo" });
            controller1.Verify(x => x.Execute(It.IsAny<ControllerContext>()));
        }
Exemple #4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            DispatcherUnhandledException += (x, y) => MessageBox.Show(y.Exception.Message);

            NavigationTransitions.Table.Add("Backward", "Forward", () => new SlideTransition(SlideDirection.Back));
            NavigationTransitions.Table.Add("Forward", "Backward", () => new SlideTransition(SlideDirection.Forward));

            var controllers = new ControllerFactory();
            controllers.Register("Home", () => new HomeController());

            var routes = new ControllerRouteCatalog(controllers);
            routes.MapRoute("{controller}/{action}");

            var navigation = new NavigatorFactory(routes);
            var mainWindow = new MainWindow();
            var navigator = navigation.CreateNavigator(mainWindow.MainFrame);
            mainWindow.Show();

            navigator.NavigateWithTransition("Home", "Index", "Forward");
        }
Exemple #5
0
		protected override void OnStartup(StartupEventArgs e)
		{
			Constants.SetApplicationName("onCore");
#if DEBUG
			MessageBox.Show("Click OK to start application.");
#endif
			Dispatcher.ShutdownStarted += (sender, args) =>
			{
				Thread.Sleep(10);	// pause for the cause
				Cleanup();
			};

			var controllerFactory = new ControllerFactory();
			Model = new GlobalViewModel();
			Model.ExecuteInUIThread += OnSafeInvoke;
			controllerFactory.Register("Global", () => new GlobalController(Model));

			ControllerBuilder.Current.SetControllerFactory(controllerFactory);
            var mainWin = new MainFrame();
            MainWindow = mainWin;
			MainWindow.DataContext = Model;
            MainWindow.Show();
			base.OnStartup(e);
		}
 public void Setup()
 {
     Factory = new AsyncControllerFactory();
 }
        public void StringableRequestsDoNotHaveAdditionalUriData()
        {
            var controller1 = new Mock<IController>();
            var controller2 = new Mock<IController>();
            var controllers = new ControllerFactory();
            controllers.Register("C1", () => controller1.Object);
            controllers.Register("C2", () => controller2.Object);
            var routes = new ControllerRouteCatalog(controllers);
            routes.MapRoute("search/{action}", new { controller = "C2" });

			var navigator = new Navigator(Factory.Object, null, "magellan", new RouteResolver(routes), () => NavigationService.Object);

            navigator.Navigate(new { controller = "C2", action = "foo" });
            controller2.Verify(x => x.Execute(It.Is<ControllerContext>(r => r.Request.HasNonUriData == false && r.Request.Uri.ToString() == "magellan://search/foo")));

            navigator.Navigate(new { controller = "C2", action = "foo", abc = "123" });
            controller2.Verify(x => x.Execute(It.Is<ControllerContext>(r => r.Request.HasNonUriData == false && r.Request.Uri.ToString() == "magellan://search/foo?abc=123")));
        }