private void Validate(HashSet <uint> taskIds, TaskDescWrapper task) { if (taskIds.Contains(task.Id)) { throw new ArgumentException($"Duplicate task id: {task.Id}"); } taskIds.Add(task.Id); if (task.CustomDesc == null) { throw new ArgumentNullException("custom desc"); } task.CustomDesc.Validate(); var decorator = task as DecoratorTaskDescWrapper; if (decorator != null) { if (decorator.ChildTaskId == 0) { throw new ArgumentException("Missing child task for decorator task"); } var childTask = FindTaskDesc(decorator.ChildTaskId); if (childTask == null) { throw new ArgumentException($"Cannot find task: #{decorator.ChildTaskId}"); } Validate(taskIds, childTask); return; } var composite = task as CompositeTaskDescWrapper; if (composite != null) { if (composite.ChildTaskIds.Count == 0) { throw new ArgumentException("Missing child task for composite task"); } foreach (var childTaskId in composite.ChildTaskIds) { var childTask = FindTaskDesc(childTaskId); if (childTask == null) { throw new ArgumentException($"Cannot find task: #{childTaskId}"); } Validate(taskIds, childTask); } return; } }
private static string GetTaskTitle(TaskDescWrapper desc) { var title = string.Format("{0} #{1}", EditorHelper.GetTaskTitle(desc.CustomDesc.GetType(), false), desc.Id); if (!string.IsNullOrEmpty(desc.Title)) { title = string.Format("{0} ({1})", title, desc.Title); } return(title); }
internal TaskBuilder(TaskDescWrapper task) { this.task = task; }