private static void PrepareApplicationAndRoutes(StartupMethods startupMethods) { var applicationBuilder = new MockedApplicationBuilder(serviceProvider); startupMethods?.ConfigureDelegate?.Invoke(applicationBuilder); AdditionalApplicationConfiguration?.Invoke(applicationBuilder); var routeBuilder = new RouteBuilder(applicationBuilder) { DefaultHandler = new RouteHandler(NullHandler) }; for (int i = 0; i < applicationBuilder.Routes.Count; i++) { var route = applicationBuilder.Routes[i]; routeBuilder.Routes.Add(route); } AdditionalRoutes?.Invoke(routeBuilder); if (StartupType == null || routeBuilder.Routes.Count == 0) { routeBuilder.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routeBuilder.Routes.Insert(0, AttributeRouting.CreateAttributeMegaRoute(serviceProvider)); } router = routeBuilder.Build(); }
private static void PrepareApplicationAndRouting() { var applicationBuilder = new ApplicationBuilderMock(routingServiceProvider); startupMethods?.ConfigureDelegate?.Invoke(applicationBuilder); AdditionalApplicationConfiguration?.Invoke(applicationBuilder); var routeBuilder = new RouteBuilder(applicationBuilder) { DefaultHandler = RouteHandlerMock.Null }; for (int i = 0; i < applicationBuilder.Routes.Count; i++) { var route = applicationBuilder.Routes[i]; routeBuilder.Routes.Add(route); } AdditionalRouting?.Invoke(routeBuilder); var routeBuilderRoutes = routeBuilder.Routes; if (StartupType == null || routeBuilderRoutes.Count == 0) { routeBuilder.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); } var attributeRoutingType = WebFramework.Internals.AttributeRouting; if (!routeBuilderRoutes[0].GetType().Name.StartsWith(nameof(Attribute))) { var createAttributeMegaRouteMethod = attributeRoutingType.GetMethod("CreateAttributeMegaRoute"); var attributeRouter = (IRouter)createAttributeMegaRouteMethod?.Invoke(null, new object[] { serviceProvider }); routeBuilderRoutes.Insert(0, attributeRouter); } router = routeBuilder.Build(); }
private static void PrepareApplicationAndRouting() { var applicationBuilder = new ApplicationBuilderMock(routingServiceProvider); var configureDelegate = startupMethods?.ConfigureDelegate; if (configureDelegate != null) { routingServiceProvider .GetService <IEnumerable <IStartupFilter> >() .Reverse() .ForEach(startupFilter => configureDelegate = startupFilter.Configure(configureDelegate)); } configureDelegate?.Invoke(applicationBuilder); AdditionalApplicationConfiguration?.Invoke(applicationBuilder); PrepareRouter(applicationBuilder); }