private async Task<IReadOnlyCollection<ContentSpec>> ProcessMods(NetworkCollection col, CollectionModelWithLatestVersion c, Game game) { var customRepos = await GetRepositories(col).ConfigureAwait(false); var groupContent = await GetGroupContent(col).ConfigureAwait(false); var deps = c.LatestVersion .Dependencies .Where(x => x.DependencyType == DependencyType.Package).ToArray(); var found = new List<Tuple<Content, string, CollectionVersionDependencyModel>>(); foreach (var d in deps) { var content = await ConvertToGroupOrRepoContent(d, col, customRepos, groupContent, game).ConfigureAwait(false); if (content == null) continue; var t = Tuple.Create(content, d.Constraint, d); found.Add(t); } var todo = deps.Except(found.Select(x => x.Item3)).ToArray(); if (todo.Any()) await SynchronizeContent(game, todo.Select(x => x.Dependency)).ConfigureAwait(false); return todo.Select(x => new ContentSpec(ConvertToContentOrLocal(x, col, game), x.Constraint)) .Where(x => x.Content != null) .Concat(found.Select(x => new ContentSpec(x.Item1, x.Item2))) .ToArray(); }
private async Task HandleContent(NetworkCollection col, CollectionModelWithLatestVersion c, CancellationToken ct, List<NetworkCollection> collections = null) { if (collections == null) collections = new List<NetworkCollection> {col}; var collectionSpecs = await ProcessEmbeddedCollections(c, collections, ct).ConfigureAwait(false); var modSpecs = await ProcessMods(col, c, await CollectionExtensions.FindOrThrowAsync(_locator.GetGameContext().Games, col.GameId) .ConfigureAwait(false)) .ConfigureAwait(false); col.ReplaceContent(modSpecs.Concat(collectionSpecs)); }