public void TransferTo(TreeProcessingList otherList) { otherList.singleItem = this.singleItem; otherList.multipleItems = this.multipleItems; otherList.addRequiresNewList = this.addRequiresNewList; this.Reset(); }
public static void ProcessActivityInstanceTree(System.Activities.ActivityInstance rootInstance, ActivityExecutor executor, Func <System.Activities.ActivityInstance, ActivityExecutor, bool> callback) { Queue <IList <System.Activities.ActivityInstance> > instancesRemaining = null; TreeProcessingList otherList = new TreeProcessingList(); otherList.Add(rootInstance); TreeProcessingList nextInstanceList = null; if (rootInstance.HasChildren) { nextInstanceList = new TreeProcessingList(); } while (((instancesRemaining != null) && (instancesRemaining.Count > 0)) || (otherList.Count != 0)) { if (otherList.Count == 0) { otherList.Set(instancesRemaining.Dequeue()); } for (int i = 0; i < otherList.Count; i++) { System.Activities.ActivityInstance instance = otherList[i]; if (callback(instance, executor) && instance.HasChildren) { instance.AppendChildren(nextInstanceList, ref instancesRemaining); } } if ((nextInstanceList != null) && (nextInstanceList.Count > 0)) { nextInstanceList.TransferTo(otherList); } else { otherList.Reset(); } } }