/// <summary> /// Determines where the Controller and Action should be based on the dynamic routing data /// </summary> /// <param name="node"></param> /// <returns></returns> private DynamicRouteConfiguration ResolveRouteValues(ITreeNode node) { string defaultController = RequestContext.RouteData.Values.ContainsKey("controller") ? RequestContext.RouteData.Values["controller"].ToString() : ""; string defaultAction = RequestContext.RouteData.Values.ContainsKey("action") ? RequestContext.RouteData.Values["action"].ToString() : ""; if (string.IsNullOrWhiteSpace(defaultController)) { defaultController = "DynamicRoute"; } if (string.IsNullOrWhiteSpace(defaultAction)) { defaultAction = "RouteValuesNotFound"; } if (node is null) { return(new DynamicRouteConfiguration(defaultController, defaultAction, null, null, DynamicRouteType.Controller, false, false)); } if (PageHasTemplate(node)) { var PageTemplateRouteConfig = new DynamicRouteConfiguration("DynamicRouteTemplate", "Index", null, null, DynamicRouteType.Controller, DynamicRouteInternalHelper.GetDefaultAddPageToCacheDependency(), false); string PageTemplateControllerName = GetPageTemplateController(node); // When the Dynamic Route Template Controller renders the Page Template, the Route Controller needs to match or it won't look in the right spot for the view if (!string.IsNullOrWhiteSpace(PageTemplateControllerName)) { PageTemplateRouteConfig.RouteValues.Add("TemplateControllerName", PageTemplateControllerName); } return(PageTemplateRouteConfig); } if (!DynamicRoutingAnalyzer.TryFindMatch(node.ClassName, out var match)) { return(new DynamicRouteConfiguration(defaultController, defaultAction, null, null, DynamicRouteType.Controller, false, false)); } return(match); }
public static bool TryFindMatch(string nodeClassName, out DynamicRouteConfiguration match) { return(classNameLookup.TryGetValue(nodeClassName.ToLowerInvariant(), out match)); }