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 ContentTreeNode() { Id = ContentTree.RootNodeId, }; foreach (var urlSegment in urlSegments) { treeNodeSummary = FindByUrlSegment(urlSegment, treeNodeSummary.Id); if (treeNodeSummary == null) return false; } return true; }
private ContentTreeNode GetTreeNodeSummaryForTreeNode(TreeNode treeNode) { var provider = contentTreeNodeProviderContext.GetProviderForTreeNode(treeNode); if (provider == null) throw new Exception(string.Format("Content tree node provider for type: {0} not found.", treeNode.Type)); var contentTreeNode = provider.GetAll().Where(a => a.Id == treeNode.TreeNodeId).FirstOrDefault(); if (contentTreeNode == null) return null; var treeNodeSummary = new ContentTreeNode() { Name = contentTreeNode.Name, Id = treeNode.TreeNodeId, UrlSegment = contentTreeNode.UrlSegment, HasChildren = treeNodeRepository.GetAll().Where(a => a.ParentTreeNodeId == treeNode.TreeNodeId).Any(), ControllerToUseForModification = provider.ControllerToUseForModification, ActionToUseForModification = provider.ActionToUseForModification, ControllerToUseForCreation = provider.ControllerToUseForCreation, ActionToUseForCreation = provider.ActionToUseForCreation, RouteValuesForModification = new { TreeNodeId = treeNode.TreeNodeId }, RouteValuesForCreation = new { ParentTreeNodeId = treeNode.TreeNodeId }, ParentTreeNodeId = treeNode.ParentTreeNodeId, Sequence = contentTreeNode.Sequence, Type = treeNode.Type, MayHaveChildNodes = provider.MayHaveChildNodes, Hidden = contentTreeNode.Hidden, IconUrl = contentTreeNode.IconUrl, LastModifyBy = contentTreeNode.LastModifyBy, LastModifyDate = contentTreeNode.LastModifyDate, Inactive = contentTreeNode.Inactive, ControllerName = provider.Controller, IsNew = contentTreeNode.IsNew }; return treeNodeSummary; }