/// <summary> /// Registers a routes. /// </summary> /// <param name="context">The area registration context.</param> /// <param name="containerBuilder">The container builder.</param> public override void RegisterCustomRoutes(WebModuleRegistrationContext context, ContainerBuilder containerBuilder) { context.MapRoute( "bcms_" + AreaName + "_MainJs", string.Format(RootModuleConstants.AutoGeneratedJsFilePathPattern, "bcms.main.js").TrimStart('/'), new { area = AreaName, controller = "Rendering", action = "RenderMainJsFile" }, new[] { typeof(RenderingController).Namespace }); context.MapRoute( "bcms_" + AreaName + "_ProcessorJs", string.Format(RootModuleConstants.AutoGeneratedJsFilePathPattern, "bcms.processor.js").TrimStart('/'), new { area = AreaName, controller = "Rendering", action = "RenderProcessorJsFile" }, new[] { typeof(RenderingController).Namespace }); context.MapRoute( "bcms_" + AreaName + "_PreviewPage", "bcms/preview/{pageId}/{pageContentId}", new { area = AreaName, controller = "Preview", action = "Index" }, new[] { typeof(PreviewController).Namespace }); CreateEmbeddedResourcesRoutes(context); // All CMS Pages: context.MapRoute("bcms_" + AreaName + "_AllPages", "{*data}", new { area = AreaName, controller = "Cms", action = "Index" }, new[] { typeof(CmsController).Namespace }); }
/// <summary> /// Creates the resource routes for 6 levels folder structure. /// </summary> /// <param name="context">The context.</param> private void CreateEmbeddedResourcesRoutes(WebModuleRegistrationContext context) { string[] urls = new[] { "file/{area}/{file}.{resourceType}/{*all}", "file/{area}/{folder1}/{file}.{resourceType}/{*all}", "file/{area}/{folder1}/{folder2}/{file}.{resourceType}/{*all}", "file/{area}/{folder1}/{folder2}/{folder3}/{file}.{resourceType}/{*all}", "file/{area}/{folder1}/{folder2}/{folder3}/{folder4}/{file}.{resourceType}/{*all}", "file/{area}/{folder1}/{folder2}/{folder3}/{folder4}/{folder5}/{file}.{resourceType}/{*all}", "file/{area}/{folder1}/{folder2}/{folder3}/{folder4}/{folder5}/{folder6}/{file}.{resourceType}/{*all}" }; int i = 0; foreach (var url in urls) { context.MapRoute( AreaName + "-level" + i++, url, new { controller = "EmbeddedResources", action = "Index" }, new { resourceType = new MimeTypeRouteConstraint() }, new[] { typeof(EmbeddedResourcesController).Namespace }); } }
/// <summary> /// Registers module controller types. /// </summary> /// <param name="registrationContext">The area registration context.</param> /// <param name="containerBuilder">The container builder.</param> /// <param name="controllerExtensions">The controller extensions.</param> public virtual void RegisterModuleControllers(WebModuleRegistrationContext registrationContext, ContainerBuilder containerBuilder, IControllerExtensions controllerExtensions) { var controllerTypes = controllerExtensions.GetControllerTypes(GetType().Assembly); if (controllerTypes != null) { var namespaces = new List <string>(); foreach (Type controllerType in controllerTypes) { string key = (AreaName + "-" + controllerType.Name).ToUpperInvariant(); if (!namespaces.Contains(controllerType.Namespace)) { namespaces.Add(controllerType.Namespace); } containerBuilder .RegisterType(controllerType) .AsSelf() .Keyed <IController>(key) .WithMetadata("ControllerType", controllerType) .InstancePerDependency() .PropertiesAutowired(PropertyWiringOptions.PreserveSetValues); } registrationContext.MapRoute( string.Format("module_{0}_internal_routes", AreaName), string.Format("{0}/{{controller}}/{{action}}", AreaName), new { area = AreaName }, namespaces.ToArray()); } }
/// <summary> /// Register a routes for the google analytics module. /// </summary> /// <param name="context">The module context.</param> /// <param name="containerBuilder">The container builder.</param> public override void RegisterCustomRoutes(WebModuleRegistrationContext context, ContainerBuilder containerBuilder) { context.MapRoute( "bcms-google-sitemap", GoogleAnalyticsModuleHelper.GetSitemapUrl(cmsConfiguration), new { area = AreaName, controller = "GoogleSitemap", action = "Index" }); }
public override void RegisterCustomRoutes(WebModuleRegistrationContext context, ContainerBuilder containerBuilder) { if (Configuration.Users != null) { if (Configuration.Users.CreateDefaultUserOnStart) { context.MapRoute( "bcms-users-register-first-user", AreaName + "/register", new { area = AreaName, controller = "Registration", action = "CreateFirstUser" }); } if (Configuration.Users.EnableCmsFormsAuthentication) { context.MapRoute( "bcms-users-login", "login", new { area = AreaName, controller = "Authentication", action = "Login" }); context.MapRoute( "bcms-users-logout", "logout", new { area = AreaName, controller = "Authentication", action = "Logout" }); } } }
public override void RegisterCustomRoutes(WebModuleRegistrationContext context, ContainerBuilder containerBuilder) { context.MapRoute( "bcms-setup-database-first-time", SetupDatabaseRoute, new { area = AreaName, controller = "Install", action = "SetupDatabase" }); context.MapRoute( "bcms-setup-database-test-connection", TestConnectionRoute, new { area = AreaName, controller = "Install", action = "TestConnection" }); }
public void Should_Map_Routes_Correctly() { var descriptor = new SampleWebModuleDescriptor(); var context = new WebModuleRegistrationContext(descriptor); var route1 = context.MapRoute("n1", "url1"); var route2 = context.MapRoute("n2", "url2", new [] { "ns1", "ns2" }); var route3 = context.MapRoute("n3", "url3", new { Default = "Default" }); var route4 = context.MapRoute("n4", "url4", new { Default = "Default" }, new { Constraint = "Constraint" }); var route5 = context.MapRoute("n5", "url5", new { Default = "Default" }, new { Constraint = "Constraint" }, new [] { "ns3", "ns4" }); var route6 = context.MapRoute("n6", "url6", new { Default = "Default" }, new[] { "ns5", "ns6" }); Assert.AreEqual(context.Routes.Count, 6); var i = 1; foreach (var route in new[] { route1, route2, route3, route4, route5, route6 }) { Assert.IsNotNull(route); Assert.AreEqual(route.Url, string.Concat("url", i)); Assert.AreEqual(route1.DataTokens["area"], descriptor.AreaName); Assert.IsTrue(context.Routes.Contains(route)); i++; } // Defaults Assert.IsEmpty(route1.Defaults); Assert.IsEmpty(route2.Defaults); Assert.IsNotEmpty(route3.Defaults); Assert.IsNotEmpty(route4.Defaults); Assert.IsNotEmpty(route5.Defaults); Assert.IsNotEmpty(route6.Defaults); // Defaults Assert.IsEmpty(route1.Constraints); Assert.IsEmpty(route2.Constraints); Assert.IsEmpty(route3.Constraints); Assert.IsNotEmpty(route4.Constraints); Assert.IsNotEmpty(route5.Constraints); Assert.IsEmpty(route6.Constraints); // Namespaces Assert.IsNull(route1.DataTokens["Namespaces"]); Assert.IsNotNull(route2.DataTokens["Namespaces"]); Assert.IsNull(route3.DataTokens["Namespaces"]); Assert.IsNull(route4.DataTokens["Namespaces"]); Assert.IsNotNull(route5.DataTokens["Namespaces"]); Assert.IsNotNull(route6.DataTokens["Namespaces"]); // Namespace fallback Assert.AreEqual(route1.DataTokens["UseNamespaceFallback"], true); Assert.AreEqual(route2.DataTokens["UseNamespaceFallback"], false); Assert.AreEqual(route3.DataTokens["UseNamespaceFallback"], true); Assert.AreEqual(route4.DataTokens["UseNamespaceFallback"], true); Assert.AreEqual(route5.DataTokens["UseNamespaceFallback"], false); Assert.AreEqual(route6.DataTokens["UseNamespaceFallback"], false); }