예제 #1
0
        public async Task TestApiRouteGenerator()
        {
            try
            {
                var client   = new TestSite("Core.Api").BuildClient();
                var response = await client.GetAsync(Router.DefaultRoute);

                var content = await response.Content.ReadAsStringAsync();

                var routesGenerated = RouteGenerator.GenerateRoutes(content);
                Assert.IsTrue(routesGenerated.Contains("namespace"));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #2
0
        public async void Start(Assembly assembly)
        {
            Host   = Browser.Window.Location.Host;
            Port   = Browser.Window.Location.Port;
            Scheme = Browser.Window.Location.Protocol;

            Browser.Window.AddEventListener("popstate", evt => OnPopState(evt.As <PopStateEvent>()));

            var path = Browser.Window.Location.PathName;

            Console.WriteLine(path);

            ControllerFactory = new DefaultControllerFactory(DependencyResolver);

            var routeGenerator = new RouteGenerator();

            routeTree = routeGenerator.GenerateRoutes(assembly);

            await OnStarting();
            await OnStarted();
        }
예제 #3
0
        public void Start(Assembly assembly)
        {
            Host   = Browser.Window.Location.Host;
            Port   = Browser.Window.Location.Port;
            Scheme = Browser.Window.Location.Protocol;

            Browser.Window.AddEventListener("popstate", evt => OnPopState(evt.As <PopStateEvent>()));

            var path = Browser.Window.Location.PathName;

            Console.WriteLine(path);

            ControllerFactory = new DefaultControllerFactory(DependencyResolver);

            var routeGenerator = new RouteGenerator();

            routeTree = routeGenerator.GenerateRoutes(assembly);

            OnStarting(() =>
            {
                Open(path + (!string.IsNullOrEmpty(Browser.Window.Location.Search) ? "?" + Browser.Window.Location.Search : ""), false, OnStarted);
            });
        }
        private async void RunDemo()
        {
            this.Timer.Stop();

            PlayButton.IsEnabled  = false;
            PauseButton.IsEnabled = false;
            StopButton.IsEnabled  = false;

            ClearCars();
            this.ViewModel.IsShowingRoutes = false;
            this.ViewModel.UpdateControls();

            var region = this.MyMap.GetVisibleRegion(MapVisibleRegionKind.Near);

            var pointGenerator = new PointGenerator();

            pointGenerator.Boundaries = region;

            var routeGenerator = new RouteGenerator(pointGenerator);

            var carModels = new List <string>()
            {
                Car.HammerheadRedUri,
                Car.HammerheadWhiteUri,
                Car.ShiftBlueUri,
                Car.ShiftGoldUri,
            };
            int model = 0;

            SimulatedTraffic.Cars   = new List <Car>();
            SimulatedTraffic.Routes = await routeGenerator.GenerateRoutes(NumberOfRoutes);

            foreach (var route in SimulatedTraffic.Routes)
            {
                //var car = new PoliceCar();
                //var car = new SchoolBus();
                var car = new Car(carModels.ElementAt(model++ % carModels.Count));
                car.Connect(this.MyMap, route);
                SimulatedTraffic.Cars.Add(car);
            }

            SimulatedTraffic.Trucks        = new List <Car>();
            SimulatedTraffic.HighwayRoutes = await routeGenerator.GenerateHighwayRoutes();

            foreach (var route in SimulatedTraffic.HighwayRoutes)
            {
                var truck = new SemiTruck();
                truck.Connect(this.MyMap, route);
                SimulatedTraffic.Trucks.Add(truck);

                var dumptruck = new DumpTruck(40);
                dumptruck.Connect(this.MyMap, route);
                SimulatedTraffic.Trucks.Add(dumptruck);

                var car = new Car(55, carModels.ElementAt(model++ % carModels.Count));
                car.Connect(this.MyMap, route);
                SimulatedTraffic.Cars.Add(car);
            }

            // Set the interval to 16ms (60 ticks / sec)
            this.Timer.Interval = new TimeSpan(0, 0, 0, 0, 1000 / UpdatesPerSecond);
            this.Timer.Start();

            this.ViewModel.UpdateControls();

            PlayButton.IsEnabled  = true;
            PauseButton.IsEnabled = true;
            StopButton.IsEnabled  = true;
        }