private void ResoleveDependenciesHierarchical(List <NeedTaskInfo> resultList, BuildTask task, int depth) { if (resultList.Find((x) => x.Task == task) == null) { resultList.Add(new NeedTaskInfo() { Task = task, Depth = depth }); } var dependencies = task.Dependencies; if (dependencies != null) { foreach (var needTaskName in dependencies) { var needTask = Tasks.Find((r) => r.CommandName == needTaskName); ResoleveDependenciesHierarchical(resultList, needTask, depth + 1); } } }