Example #1
0
 /// <summary>
 /// Recursively clones children of the specified activity and inserts them into the clone tree.
 /// </summary>
 /// <param name="navigator">The cloned navigator data object.</param>
 /// <param name="cloneParent">The cloned parent to add the children to.</param>
 /// <param name="originalParent">The original parent to clone the children from.</param>
 protected void CloneChildren(NavigatorData navigator, Activity cloneParent, Activity originalParent)
 {
     foreach (Activity child in originalParent.Children)
     {
         Activity clone = child.CloneForNavigationTest();
         cloneParent.AddChild(clone);
         clone.Parent = cloneParent;
         if (CurrentActivity == child)
         {
             navigator.CurrentActivity = clone;
         }
         if (SuspendedActivity == child)
         {
             navigator.SuspendedActivity = clone;
         }
         navigator.Activities.Add(clone.ActivityId, clone);
         CloneChildren(navigator, clone, child);
     }
 }
Example #2
0
            /// <summary>
            /// Applies any randomization to a cluster, if applicable
            /// </summary>
            /// <param name="rootOfCluster">The root of the cluster to randomize.</param>
            static private void ApplyRandomization(Activity rootOfCluster)
            {
#if DEBUG
                Random rand;
                if(NavigatorData.Random != null)
                {
                    rand = NavigatorData.Random;
                }
                else
                {
                    rand = new Random();
                }
#else
                Random rand = new Random();
#endif

                // if this activity has requested randomization of its children and 
                // it is not the first attempt on this activity (this case is handled when
                // the tree is first created), randomize the children.
                if(rootOfCluster.Sequencing.RandomizationTiming == RandomizationTiming.OnEachNewAttempt &&
                    rootOfCluster.Sequencing.ReorderChildren &&
                    rootOfCluster.DataModel.ActivityAttemptCount > 0)
                {
                    List<Activity> randlist = new List<Activity>();
                    while(rootOfCluster.Children.Count > 0)
                    {
                        int i = rand.Next(rootOfCluster.Children.Count);
                        randlist.Add((Activity)rootOfCluster.Children[i]);
                        rootOfCluster.RemoveChild(i);
                    }
                    for(int i = 0 ; i < randlist.Count ; ++i)
                    {
                        randlist[i].RandomPlacement = i;
                        rootOfCluster.AddChild(randlist[i]);
                    }
                    rootOfCluster.SortChildren();
                }
            }
Example #3
0
 /// <summary>
 /// Recursively clones children of the specified activity and inserts them into the clone tree.
 /// </summary>
 /// <param name="navigator">The cloned navigator data object.</param>
 /// <param name="cloneParent">The cloned parent to add the children to.</param>
 /// <param name="originalParent">The original parent to clone the children from.</param>
 protected void CloneChildren(NavigatorData navigator, Activity cloneParent, Activity originalParent)
 {
     foreach(Activity child in originalParent.Children)
     {
         Activity clone = child.CloneForNavigationTest();
         cloneParent.AddChild(clone);
         clone.Parent = cloneParent;
         if(CurrentActivity == child)
         {
             navigator.CurrentActivity = clone;
         }
         if(SuspendedActivity == child)
         {
             navigator.SuspendedActivity = clone;
         }
         navigator.Activities.Add(clone.ActivityId, clone);
         CloneChildren(navigator, clone, child);
     }
 }