/// <summary>
 /// Wraps a mutate function so it can be called without the MutateType param
 /// </summary>
 protected Action<WorkPackageDTO> WrapMutateFunction(Action<WorkPackageDTO, MutateType> fn, MutateType type)
 {
     return wp => fn(wp, type);
 }
예제 #2
0
        public static void ChildTasks(WorkPackageDTO wp, MutateType type)
        {
            var indices = Helper.GenerateShuffledIndexList(wp.Tasks);
            indices.Sort((a, b) => b - a); // to make removal easier, sort it in reverse order
            switch (type)
            {
                case MutateType.Add:
                    for (var i = 0; i < indices.Count; i++)
                    {
                        wp.Tasks.Add(Generate.Task());
                    }
                    break;

                case MutateType.Remove:
                    foreach (var i in indices)
                    {
                        wp.Tasks.RemoveAt(i);
                    }
                    break;

                case MutateType.Modify:
                    foreach (var i in indices)
                    {
                        Mutate.Task(wp.Tasks.ElementAt(i));
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException("type", type, null);
            }
        }