/// <summary> /// Tests the node. /// </summary> /// <param name="node">The node.</param> /// <param name="flags">The flags.</param> /// <param name="types">The types.</param> /// <returns></returns> internal static Boolean testNode(this imbTreeNode node, imbTreeQueryFlag flag, imbTreeNodeType types) { var flags = flag.getEnumListFromFlags <imbTreeQueryFlag>(); if (flags.Contains(imbTreeQueryFlag.collectAll)) { return(true); } if (node is imbTreeNodeLeaf) { if (flags.ContainsOneOrMore(imbTreeQueryFlag.collectAllLeafs)) { return(true); } } else { if (flags.ContainsOneOrMore(imbTreeQueryFlag.collectAllBranches)) { return(true); } } if (flags.Contains(imbTreeQueryFlag.collectAllOfNodeType)) { return(types.HasFlag(node.nodeType())); } return(false); }
/// <summary> /// Vraca sve node-ove koji ispunjavaju uslove upita date u imbTreeNodeType i imbTreeQueryFlag enumima /// </summary> /// <param name="parentNode">Node nad kojim se vrsi upit</param> /// <param name="depthLimit">Limit koliko duboko moze da ide upit</param> /// <param name="_flags">imbTreeNodeType i imbTreeQueryFlag enumi kojima se podesava upit</param> /// <returns>Kolekcija</returns> public static imbTreeNodeCollection query(this imbTreeNodeBranch parentNode, Int32 depthLimit, params Object[] _flags) { imbTreeQueryFlag flags = _flags.getFirstOfType <imbTreeQueryFlag>(); // = new imbTreeQueryFlags(_flags); imbTreeNodeType types = _flags.getFirstOfType <imbTreeNodeType>(); // = new imbTreeNodeTypes(_flags); imbTreeNodeCollection output = new imbTreeNodeCollection(); Int32 i = 0; List <imbTreeNode> toDo = new List <imbTreeNode>(); List <imbTreeNode> newToDo = new List <imbTreeNode>(); toDo.Add(parentNode); do { if (i > depthLimit) { //logSystem.log("Depth limit reached on imbTreeQuery :: ", logType.ExecutionError); break; } newToDo = new List <imbTreeNode>(); foreach (imbTreeNode nd in toDo) { if (nd.testNode(flags, types)) { output.Add(nd.path, nd); } if (nd is imbTreeNodeBranch) { imbTreeNodeBranch bnd = nd as imbTreeNodeBranch; foreach (var t in bnd) { newToDo.Add(t.Value); } } } i++; toDo = newToDo; } while (toDo.Count > 0); return(output); }