private void EnqueueDependencies(MigrationItem completedItem, ConcurrentQueue <MigrationItem> queue, TextWriter log) { lock (syncRoot) { // mark item as processed itemsInProgress.Remove(completedItem.ObjectId); // and check all child items dependencies foreach (var childItem in GetChildDependencies(completedItem).Where(HasNoDependencies)) { log.WriteLine($"Add {childItem} into a queue."); queue.Enqueue(childItem); } } }
private IEnumerable <MigrationItem> GetChildDependencies(MigrationItem item) { MigrationItem[] childs; return(dependenciesChild.TryGetValue(item.ObjectId, out childs) ? childs : Enumerable.Empty <MigrationItem>()); }
private bool HasNoDependencies(MigrationItem item) { int[] parents; return(!dependenciesParent.TryGetValue(item.ObjectId, out parents) || parents.All(id => !itemsInProgress.Contains(id))); }