private string GetJobDependencies(Job current, string result, IList<Job> jobs) { if (result.Contains(current.Name)) return ""; if (string.IsNullOrEmpty(current.DependencyName)) return current.Name; ThrowIfCircularDependencyFound(current); return GetJobDependencies(jobs.Single(x => x.Name == current.DependencyName), result, jobs) + current.Name; }
private static Job ParseJob(string jobLine) { var split = jobLine.Split(new[] { "=>" }, StringSplitOptions.RemoveEmptyEntries); var job = new Job { Name = split[0].Trim() }; if (split.Length > 1) job.DependencyName = split[1].Trim(); return job; }
private void ThrowIfCircularDependencyFound(Job current) { if (_jobsSeen.Contains(current.Name)) throw new ArgumentException("Circular dependency detected!"); _jobsSeen.Add(current.Name); }