public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { var urlSegments = from value in values where value.Key.StartsWith("nodesegment") where value.Value is string orderby value.Key.Split('-')[1] select (string)value.Value; if (urlSegments.Count() == 0) return false; var treeNodeSummary = new TreeNodeSummary() { Id = Constants.RootNodeId, }; foreach (var urlSegment in urlSegments) { treeNodeSummary = FindByUrlSegment(urlSegment, treeNodeSummary.Id); if (treeNodeSummary == null) return false; } return true; }
private TreeNodeSummary GetTreeNodeSummaryForTreeNode(TreeNode treeNode) { var provider = treeNodeProviderContext.GetProviderByTypeName(treeNode.Type); if (provider == null) throw new Exception(string.Format("Content tree node provider for type: {0} not found.", treeNode.Type)); var treeNodeExtension = provider.GetAll().Where(a => a.TreeNodeId == treeNode.Id).FirstOrDefault(); if (treeNodeExtension == null) return null; var treeNodeSummary = new TreeNodeSummary() { Name = treeNodeExtension.Name, Id = treeNode.Id, UrlSegment = treeNodeExtension.UrlSegment, HasChildren = treeNodeRepository.GetAll().Where(a => a.ParentTreeNodeId == treeNode.Id).Any(), ControllerToUseForModification = provider.ControllerToUseForModification, ActionToUseForModification = provider.ActionToUseForModification, ControllerToUseForCreation = provider.ControllerToUseForCreation, ActionToUseForCreation = provider.ActionToUseForCreation, RouteValuesForModification = new { TreeNodeId = treeNode.Id }, RouteValuesForCreation = new { ParentTreeNodeId = treeNode.Id }, ParentTreeNodeId = treeNode.ParentTreeNodeId, Sequence = treeNodeExtension.Sequence, Type = treeNode.Type, MayHaveChildNodes = provider.MayHaveChildNodes, Hidden = treeNodeExtension.Hidden, IconUrl = treeNodeExtension.IconUrl, LastModifyBy = treeNodeExtension.LastModifyBy, LastModifyDate = treeNodeExtension.LastModifyDate, Active = !treeNodeExtension.Inactive }; return treeNodeSummary; }