// ---------------------------------------- /// <summary> /// Finding all ancestors (all boxes box) with given box type in Ferda Archive tree structure /// </summary> /// <param name="Box">Box in archive, for which function searches the ancestors</param> /// <param name="ID">type of searched boxes (string identifier)</param> /// <returns></returns> public static IBoxModule[] ListAncestBoxesWithID(IBoxModule Box, string ID) { ArrayList MyBoxes = new ArrayList(); IBoxModule[] Ancestors = Box.ConnectionsFrom().ToArray(); foreach (IBoxModule b in Ancestors) { if (b.MadeInCreator.Identifier == ID) // this ancestor has desired type MyBoxes.Add(b); else // ancestor doesn't have desired type. Further we searche among it's ancestors (recurse) { IBoxModule[] b_ancestors = ListAncestBoxesWithID(b, ID); // recurse foreach (IBoxModule bb in b_ancestors) MyBoxes.Add(bb); } } // eliminating the duplicites MyBoxes.Sort(); IBoxModule[] SortedBoxes = (IBoxModule[])MyBoxes.ToArray(typeof(IBoxModule)); ArrayList MyUniqueBoxes = new ArrayList(); foreach (IBoxModule bbb in SortedBoxes) { if (MyUniqueBoxes.BinarySearch(bbb) < 0) MyUniqueBoxes.Add(bbb); } IBoxModule[] resultArray = (IBoxModule[])MyUniqueBoxes.ToArray(typeof(IBoxModule)); return resultArray; }
// ---------------------------------------- /// <summary> /// Finding all direct ancestors (all boxes box) with given box type in Ferda Archive tree structure /// </summary> /// <param name="Box">Box in archive, for which function searches the ancestors</param> /// <param name="ID">type of searched boxes (string identifier)</param> /// <returns></returns> public static IBoxModule[] ListDirectAncestBoxesWithID(IBoxModule Box, string ID) { ArrayList MyBoxes = new ArrayList(); IBoxModule[] Ancestors = Box.ConnectionsFrom().ToArray(); foreach (IBoxModule b in Ancestors) { if (b.MadeInCreator.Identifier == ID) { MyBoxes.Add(b); } } return(MyBoxes.ToArray(typeof(IBoxModule)) as IBoxModule[]); }
// ---------------------------------------- /// <summary> /// Finding all ancestors (all boxes box) with given box type in Ferda Archive tree structure /// </summary> /// <param name="Box">Box in archive, for which function searches the ancestors</param> /// <param name="ID">type of searched boxes (string identifier)</param> /// <returns></returns> public static IBoxModule[] ListAncestBoxesWithID(IBoxModule Box, string ID) { ArrayList MyBoxes = new ArrayList(); IBoxModule[] Ancestors = Box.ConnectionsFrom().ToArray(); foreach (IBoxModule b in Ancestors) { if (b.MadeInCreator.Identifier == ID) // this ancestor has desired type { MyBoxes.Add(b); } else // ancestor doesn't have desired type. Further we searche among it's ancestors (recurse) { IBoxModule[] b_ancestors = ListAncestBoxesWithID(b, ID); // recurse foreach (IBoxModule bb in b_ancestors) { MyBoxes.Add(bb); } } } // eliminating the duplicites MyBoxes.Sort(); IBoxModule[] SortedBoxes = (IBoxModule[])MyBoxes.ToArray(typeof(IBoxModule)); ArrayList MyUniqueBoxes = new ArrayList(); foreach (IBoxModule bbb in SortedBoxes) { if (MyUniqueBoxes.BinarySearch(bbb) < 0) { MyUniqueBoxes.Add(bbb); } } IBoxModule[] resultArray = (IBoxModule[])MyUniqueBoxes.ToArray(typeof(IBoxModule)); return(resultArray); }
/// <summary> /// Finding all direct ancestors (all boxes box) with given box type in Ferda Archive tree structure /// </summary> /// <param name="Box">Box in archive, for which function searches the ancestors</param> /// <param name="ID">list with types of searched boxes (string identifiers)</param> /// <returns></returns> public static IBoxModule[] ListDirectAncestBoxesWithID(IBoxModule Box, string[] IDs) { ArrayList MyBoxes = new ArrayList(); IBoxModule[] Ancestors = Box.ConnectionsFrom().ToArray(); foreach (IBoxModule b in Ancestors) { foreach (string ID in IDs) { if (b.MadeInCreator.Identifier == ID) MyBoxes.Add(b); } } return (MyBoxes.ToArray(typeof(IBoxModule)) as IBoxModule[]); }
private void lockUnlockRecursive(IBoxModule box, BoxModule lockBox, Stack<IBoxModule> stack, bool locking) { BoxModule boxModule = box as BoxModule; if(boxModule!=null) { if(locking) boxModule.LockByBox(lockBox); else boxModule.UnlockByBox(lockBox); } else { foreach(IBoxModule newBox in box.ConnectionsFrom()) { if(!stack.Contains(newBox)) { stack.Push(newBox); lockUnlockRecursive(newBox, lockBox, stack, locking); stack.Pop(); } } } }