public void AddRestRequestHandler(RestDigestibleUri uri, RestMethod method, RestRequestHandler handler) { if (uri.IsLastNode || this is WildCardUriRequestHandlerNode) { switch (method) { case RestMethod.GET: if (HttpGetRequestHandler != null) { throw new Exception("Handler already defined"); } HttpGetRequestHandler = handler; return; case RestMethod.POST: if (HttpPostRequestHandler != null) { throw new Exception("Handler already defined"); } HttpPostRequestHandler = handler; return; default: throw new Exception("Unknown REST Method."); } } uri.NextNode(); foreach (var childNode in ChildNodes) { if (childNode.MatchesUriPattern(uri) && ((childNode is ParameterUriRequestHandlerNode && uri.IsCurrentNodeParameterDefinition) || childNode is NamedUriRequestHandlerNode && !uri.IsCurrentNodeParameterDefinition)) { childNode.AddRestRequestHandler(uri, method, handler); return; } } UriRequestHandlerNode newChildNode; if (uri.IsCurrentNodeParameterDefinition) { newChildNode = new ParameterUriRequestHandlerNode(uri, method, handler); } else if (uri.IsWildCardNodeDefinition) { newChildNode = new WildCardUriRequestHandlerNode(uri, method, handler); } else { newChildNode = new NamedUriRequestHandlerNode(uri, method, handler); } ChildNodes.Add(newChildNode); ChildNodes = ChildNodes.OrderBy(n => n.GetSearchPriority()).ToList(); }
public IEnumerable <HierarchyNode <T> > NodesToListOrdered() { var result = new List <HierarchyNode <T> >(); result.Add(this); if (ChildNodes != null) { var sortedChildNodes = ChildNodes.OrderBy(o => (o.Entity as OrderedModelBase).Order); foreach (var childNode in ChildNodes) { result.AddRange(childNode.NodesToListOrdered()); } } return(result); }
public void QueueNodes(ICollection <DependencyNode <T> > nodes) { Visited = true; foreach (var parentNode in ParentNodes.OrderBy(x => x.OutgoingWeight)) { if (parentNode.Visited) { continue; } parentNode.QueueNodes(nodes); } nodes.Add(this); foreach (var childNode in ChildNodes.OrderBy(x => x.OutgoingWeight)) { if (childNode.Visited) { continue; } childNode.QueueNodes(nodes); } }
protected void ShuffleNodes() => ChildNodes = ChildNodes.OrderBy(g => Guid.NewGuid()).ToList();
public List <PlanNodeDO> GetOrderedChildren() { return(ChildNodes.OrderBy(x => x.Ordering).ToList()); }