Rebel.Cms.Web.Mvc.Areas.RebelAreaRegistration.MapRouteEditors C# (CSharp) Method

MapRouteEditors() private method

Creates the routing rules for the editors
private MapRouteEditors ( RouteCollection routes, IEnumerable editorControllers ) : void
routes RouteCollection
editorControllers IEnumerable
return void
        private void MapRouteEditors(RouteCollection routes, IEnumerable<EditorMetadata> editorControllers)
        {
            //first, register the internal/default Rebel editor routes (so they work without the IDs)
            //but the constraint will ONLY allow built in Rebel editors to work like this, 3rd party 
            //editors will only be accessible by using an ID.
            var defaultEditorMetadata = editorControllers.Where(x => x.IsInternalRebelEditor);                

            //first register the special DashboardEditorController as the default
            var dashboardControllerName = RebelController.GetControllerName(typeof(DashboardEditorController));
            var dashboardControllerId = RebelController.GetControllerId<EditorAttribute>(typeof(DashboardEditorController));
            var route = routes.MapRoute(
                DashboardRouteName,//name
                AreaName + "/Editors/" + dashboardControllerName + "/{action}/{appAlias}",//url to match
                new { controller = dashboardControllerName, action = "Dashboard", appAlias = "content", editorId = dashboardControllerId.ToString("N") },
                new { backOffice = new BackOfficeRouteConstraint(_applicationContext) },
                new[] { typeof(DashboardEditorController).Namespace }); //only match this namespace
            route.DataTokens.Add("area", AreaName); //only match this area
            route.DataTokens.Add("rebel", "backoffice"); //ensure the rebel token is set

            //register the default (built-in) editors
            foreach (var t in defaultEditorMetadata)
            {
                this.RouteControllerPlugin(t.Id, t.ControllerName, t.ComponentType, routes, "editorId", "Editor", "Editors", "Dashboard", UrlParameter.Optional, true, _applicationContext);
            }

            //now, we need to get the 'internal' editors, these could be not part of a package and just exist in the 'bin' if someone just developed their
            //trees in VS in their local Rebel project
            var localEditors = editorControllers.Where(x => x.PluginDefinition == null && x.Id != dashboardControllerId);
            foreach (var t in localEditors)
            {
                this.RouteControllerPlugin(t.Id, t.ControllerName, t.ComponentType, routes, "editorId", "Editor", "Editors", "Dashboard", UrlParameter.Optional, true, _applicationContext);
            }

        }