private void MapRouteTrees(RouteCollection routes, IEnumerable<TreeMetadata> treeControllers)
{
//get the core ubmraco trees
var defaultTreeTypes = treeControllers.Where(x => x.IsInternalRebelTree);
//First, register the special default route for the ApplicationTreeController, this is required
//because this special tree doesn't take a HiveId as a parameter but an application name (string)
//in order for it to render all trees in the application routed
var applicationTreeControllerName = RebelController.GetControllerName(typeof(ApplicationTreeController));
var applicationTreeControllerId = RebelController.GetControllerId<TreeAttribute>(typeof(ApplicationTreeController));
var route = routes.MapRoute(
ApplicationTreeRouteName,//name
AreaName + "/Trees/" + applicationTreeControllerName + "/{action}/{appAlias}",//url to match
new { controller = applicationTreeControllerName, action = "Index", appAlias = "content", treeId = applicationTreeControllerId.ToString("N") },
new { backOffice = new BackOfficeRouteConstraint(_applicationContext) },
new[] { typeof(ApplicationTreeController).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 routes for the default trees
foreach (var t in defaultTreeTypes)
{
this.RouteControllerPlugin(t.Id, t.ControllerName, t.ComponentType, routes, "treeId", "Tree", "Trees", "Index", HiveId.Empty, true, _applicationContext);
}
//now, we need to get the 'internal' trees, 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 localTrees = treeControllers.Where(x => x.PluginDefinition == null && x.Id != applicationTreeControllerId);
foreach (var t in localTrees)
{
this.RouteControllerPlugin(t.Id, t.ControllerName, t.ComponentType, routes, "treeId", "Tree", "Trees", "Index", HiveId.Empty, true, _applicationContext);
}
}