/// <summary> /// gets all children of the current node (those with paths that begin with the current node's path) /// </summary> /// <param name="nodeStore"></param> /// <returns></returns> public static List <GraphNode> GetChildNodes(this IStoreOf <GraphNode> nodeStore, GraphPath path) { Condition.Requires(nodeStore).IsNotNull(); var matches = nodeStore.SearchOf(LogicOfTo <GraphNode, bool> .New((x) => { return(x.Path.Path.StartsWith(path.Path)); })); return(matches); }
/// <summary> /// given a nodestore finds the current node's parent node /// </summary> /// <param name="nodeStore"></param> /// <returns></returns> public static GraphNode GetParentNode(this IStoreOf <GraphNode> nodeStore, GraphPath path) { Condition.Requires(nodeStore).IsNotNull(); GraphNode rv = null; //if we're on a root node, there is no parent if (path.IsRoot) { return(null); } var parentPath = path.ParentPath; var matches = nodeStore.SearchOf(LogicOfTo <GraphNode, bool> .New((x) => { return(x.Id.Equals(parentPath)); })); rv = matches.FirstOrDefault(); return(rv); }