protected void Application_Start() { //AreaRegistration.RegisterAllAreas(); var adminArea = new AdminAreaRegistration(); var adminAreaContext = new AreaRegistrationContext(adminArea.AreaName, RouteTable.Routes); adminArea.RegisterArea(adminAreaContext); var defaultArea = new DefaultAreaRegistration(); var defaultAreaContext = new AreaRegistrationContext(defaultArea.AreaName, RouteTable.Routes); defaultArea.RegisterArea(defaultAreaContext); //WebApiConfig.Register(GlobalConfiguration.Configuration); //FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); //RouteConfig.RegisterRoutes(RouteTable.Routes); //BundleConfig.RegisterBundles(BundleTable.Bundles); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); /*AreaRegistration.RegisterAllAreas(); * * WebApiConfig.Register(GlobalConfiguration.Configuration); * FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); * RouteConfig.RegisterRoutes(RouteTable.Routes); * BundleConfig.RegisterBundles(BundleTable.Bundles);*/ }
private void TestIncomingRoute(string url, Dictionary <string, string> route) { RouteCollection routes = new RouteCollection(); var adminArea = new AdminAreaRegistration(); var businessArea = new BusinessAreaRegistration(); adminArea.RegisterArea(new AreaRegistrationContext(adminArea.AreaName, routes)); businessArea.RegisterArea(new AreaRegistrationContext(businessArea.AreaName, routes)); MvcApplication.RegisterRoutes(routes); var httpContext = GetMockHttpContext(url); var routeData = routes.GetRouteData(httpContext.Object); Assert.IsNotNull(routeData, "route data should not be null"); Assert.IsNotNull(routeData.Route, "route should not be null"); foreach (var key in route.Keys) { if (route[key] == null) { Assert.IsNull(routeData.Values[key]); } else { Assert.AreEqual(route[key], routeData.Values[key], "unexptected value for {0}", key); } } }
protected void Application_Start() { //AreaRegistration.RegisterAllAreas(); var adminArea = new AdminAreaRegistration(); var adminAreaContext = new AreaRegistrationContext(adminArea.AreaName, RouteTable.Routes); adminArea.RegisterArea(adminAreaContext); var defaultArea = new DefaultAreaRegistration(); var defaultAreaContext = new AreaRegistrationContext(defaultArea.AreaName, RouteTable.Routes); defaultArea.RegisterArea(defaultAreaContext); //WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); VetDBDataContext data = new VetDBDataContext(); try { data.CreateDatabase(); } catch { } }
public void RouteCollectionSetup() { var areaReg = new AdminAreaRegistration(); var areaContext = new AreaRegistrationContext(areaReg.AreaName, RouteTable.Routes); areaReg.RegisterArea(areaContext); RouteConfig.RegisterRoutes(RouteTable.Routes); this.routeCollection = RouteTable.Routes; }
public void RouteCollectionSetup() { var area2Reg = new AdminAreaRegistration(); var area2Context = new AreaRegistrationContext(area2Reg.AreaName, RouteTable.Routes); area2Reg.RegisterArea(area2Context); RouteConfig.RegisterRoutes(RouteTable.Routes); this.routeCollection = RouteTable.Routes; }
public void TestRouteAdminUsersIndex() { const string Url = "/Admin/Users"; const string AreaName = "Admin"; var routeCollection = new RouteCollection(); var areaRegistration = new AdminAreaRegistration(); Assert.AreEqual(AreaName, areaRegistration.AreaName); var areaRegistrationContext = new AreaRegistrationContext(areaRegistration.AreaName, routeCollection); areaRegistration.RegisterArea(areaRegistrationContext); routeCollection.ShouldMap(Url).To<UsersController>(c => c.Index()); }
public void SetLowercaseUrlsToTrue_WhenRegistrationContextIsProvided() { // Arrange AdminAreaRegistration registration = new AdminAreaRegistration(); AreaRegistrationContext context = new AreaRegistrationContext( registration.AreaName, new RouteCollection()); // Act registration.RegisterArea(context); // Assert Assert.That(context.Routes.LowercaseUrls, Is.EqualTo(true)); }
private void TestRouteFail(string url) { var routes = new RouteCollection(); var adminAreaRegistration = new AdminAreaRegistration(); var registrationContext = new AreaRegistrationContext("Admin", routes); adminAreaRegistration.RegisterArea(registrationContext); RouteConfig.RegisterRoutes(routes); var httpContext = GetHttpContext(url); var result = routes.GetRouteData(httpContext); Assert.IsNull(result?.Route); }
public RoutingTests() { Routes = new RouteCollection(); var httpContextBase = Substitute.For <HttpContextBase>(); httpContextBase.Server.MapPath(Arg.Any <string>()).Returns(@"c:\folderthatdoesntexist"); var adminAreaRegistration = new AdminAreaRegistration(new Lazy <HttpContextBase>(() => httpContextBase)); var areaRegistrationContext = new AreaRegistrationContext(adminAreaRegistration.AreaName, Routes); adminAreaRegistration.RegisterArea(areaRegistrationContext); RouteConfig.RegisterRoutes(Routes); }
public static void RegisterAreas() { // // Admin area . . . var adminArea = new AdminAreaRegistration(); var adminAreaContext = new AreaRegistrationContext(adminArea.AreaName, RouteTable.Routes); adminArea.RegisterArea(adminAreaContext); // // Default area . . . var defaultArea = new DefaultAreaRegistration(); var defaultAreaContext = new AreaRegistrationContext(defaultArea.AreaName, RouteTable.Routes); defaultArea.RegisterArea(defaultAreaContext); }
protected void Application_Start() { var adminArea = new AdminAreaRegistration(); var adminAreaContext = new AreaRegistrationContext(adminArea.AreaName, RouteTable.Routes); adminArea.RegisterArea(adminAreaContext); var defaultArea = new DefaultAreaRegistration(); var defaultAreaContext = new AreaRegistrationContext(defaultArea.AreaName, RouteTable.Routes); defaultArea.RegisterArea(defaultAreaContext); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); }
private void TestRouteMatch(string url, Dictionary <string, string> routeValues, string httpMethod = "GET") { var routes = new RouteCollection(); var adminAreaRegistration = new AdminAreaRegistration(); var registrationContext = new AreaRegistrationContext("Admin", routes); adminAreaRegistration.RegisterArea(registrationContext); RouteConfig.RegisterRoutes(routes); var httpContext = GetHttpContext(url, httpMethod); var result = routes.GetRouteData(httpContext); Assert.IsNotNull(result); Assert.IsTrue(TestIncomingRouteResult(result, routeValues)); }
private string GenerateUrlFromMock(object values) { var routes = new RouteCollection(); var adminArea = new AdminAreaRegistration(); var businessArea = new BusinessAreaRegistration(); adminArea.RegisterArea(new AreaRegistrationContext(adminArea.AreaName, routes)); businessArea.RegisterArea(new AreaRegistrationContext(businessArea.AreaName, routes)); MvcApplication.RegisterRoutes(routes); var context = GetMockHttpContext(null); var reqContext = new RequestContext(context.Object, new RouteData()); return(UrlHelper.GenerateUrl(null, null, null, new RouteValueDictionary(values), routes, reqContext, true)); }
protected void Application_Start() { logger.Info("Application Start"); // RegisterAllAreas() регистрирует все найденные объявления area, но она нам не подходит, // так как если DefaultArea зарегистрировать раньше AdminArea, то будет срабатывать маршрутизация Default, // а в админку мы уже не сможем попасть, поэтому исправляем //AreaRegistration.RegisterAllAreas(); var adminArea = new AdminAreaRegistration(); var adminAreaContext = new AreaRegistrationContext(adminArea.AreaName, RouteTable.Routes); adminArea.RegisterArea(adminAreaContext); var defaultArea = new DefaultAreaRegistration(); var defaultAreaContext = new AreaRegistrationContext(defaultArea.AreaName, RouteTable.Routes); defaultArea.RegisterArea(defaultAreaContext); //FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); // RouteConfig.RegisterRoutes(RouteTable.Routes); //BundleConfig.RegisterBundles(BundleTable.Bundles); }
/// <summary> /// Вызывается, когда первый экземпляр HttpApplication создается. Это позволяет создавать объекты доступные для всех экземпляров класса HttpApplication. /// </summary> protected void Application_Start() { _logger.Info("Application starting"); #region AreasRegistration var adminArea = new AdminAreaRegistration(); var adminAreaContext = new AreaRegistrationContext(adminArea.AreaName, RouteTable.Routes); adminArea.RegisterArea(adminAreaContext); var defaultArea = new DefaultAreaRegistration(); var defaultAreaContext = new AreaRegistrationContext(defaultArea.AreaName, RouteTable.Routes); defaultArea.RegisterArea(defaultAreaContext); #endregion //если сразу регистрировать все области, то сначала зарегается Default и тогда до Admin будет не достучаться //поэтому используем код выше //AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); Database.SetInitializer <PracticeContext>(new EFDbInitializer()); CommonMapper.Configurate(); }
protected void Application_Start() { PreStartApp.logger.Info("Application Start"); var adminArea = new AdminAreaRegistration(); var adminAreaContext = new AreaRegistrationContext(adminArea.AreaName, RouteTable.Routes); adminArea.RegisterArea(adminAreaContext); var defaultArea = new DefaultAreaRegistration(); var defaultAreaContext = new AreaRegistrationContext(defaultArea.AreaName, RouteTable.Routes); defaultArea.RegisterArea(defaultAreaContext); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); mailThread = new Thread(new ThreadStart(ThreadFunc)); mailThread.Start(); DefaultModelBinder.ResourceClassKey = "Messages"; }
protected void Application_Start() { GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter); GlobalConfiguration.Configure(WebApiConfig.Register); var adminArea = new AdminAreaRegistration(); var adminAreaContext = new AreaRegistrationContext(adminArea.AreaName, RouteTable.Routes); adminArea.RegisterArea(adminAreaContext); var mapArea = new MapAreaRegistration(); var mapAreaContext = new AreaRegistrationContext(mapArea.AreaName, RouteTable.Routes); mapArea.RegisterArea(mapAreaContext); var defaultArea = new DefaultAreaRegistration(); var defaultAreaContext = new AreaRegistrationContext(defaultArea.AreaName, RouteTable.Routes); defaultArea.RegisterArea(defaultAreaContext); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); // Рассылка актуальной версии карты Task.Factory.StartNew(() => { while (true) { MapHub.BroadcastSystems(); Thread.Sleep(10000); } }); }