private static Content ConvertToContentOrLocal(CollectionVersionDependencyModel x, IHaveGameId col,
                                                Game game) => (Content)game.NetworkContent.FirstOrDefault(
     cnt =>
     cnt.PackageName.Equals(x.Dependency,
                            StringComparison.CurrentCultureIgnoreCase))
 ??
 new ModLocalContent(x.Dependency.ToLower(),
                     col.GameId,
                     new BasicInstallInfo());
            private async Task <ContentSpec> ProcessEmbeddedCollection(
                IEnumerable <CollectionModelWithLatestVersion> cols, CollectionVersionDependencyModel ec,
                List <NetworkCollection> collections, CancellationToken ct)
            {
                var rc   = cols.First(c2 => c2.Id == ec.CollectionDependencyId.Value);
                var conv = await MapCollection(rc, ct, collections).ConfigureAwait(false);

                collections.Add(conv);
                return(new ContentSpec(conv, ec.Constraint));
            }
            private async Task <Content> ConvertToGroupOrRepoContent(CollectionVersionDependencyModel x, Collection col,
                                                                     IReadOnlyCollection <CustomRepo> customRepos, IEnumerable <GroupContent> groupContent, Game game)
            {
                var gc =
                    groupContent.FirstOrDefault(
                        c => c.PackageName.Equals(x.Dependency, StringComparison.CurrentCultureIgnoreCase));

                if (gc != null)
                {
                    // TODO: dependencies etc
                    return(new ModNetworkGroupContent(gc.Id, gc.PackageName, gc.GameId, gc.Version));
                }
                return(await HandleRepoContent(x, col, customRepos, game).ConfigureAwait(false));
            }
            private async Task <Content> HandleRepoContent(CollectionVersionDependencyModel x, Collection col,
                                                           IReadOnlyCollection <CustomRepo> customRepos, Game game)
            {
                var repo = customRepos.FirstOrDefault(r => r.HasMod(x.Dependency));

                if (repo == null)
                {
                    return(null);
                }
                var repoContent = repo.GetMod(x.Dependency);
                var mod         = new ModRepoContent(x.Dependency, col.GameId, repoContent.Value.GetVersionInfo());

                if (repoContent.Value.Dependencies != null)
                {
                    mod.Dependencies = await GetDependencyTree(repoContent, customRepos, game).ConfigureAwait(false);
                }
                return(mod);
            }
 private static Content ConvertToContentOrLocal(CollectionVersionDependencyModel x, IHaveGameId col,
     Game game) => (Content) game.NetworkContent.FirstOrDefault(
                       cnt =>
                           cnt.PackageName.Equals(x.Dependency,
                               StringComparison.CurrentCultureIgnoreCase))
                   ??
                   new ModLocalContent(x.Dependency.ToLower(),
                       col.GameId,
                       new BasicInstallInfo());
 private async Task<Content> HandleRepoContent(CollectionVersionDependencyModel x, Collection col,
     IReadOnlyCollection<CustomRepo> customRepos, Game game) {
     var repo = customRepos.FirstOrDefault(r => r.HasMod(x.Dependency));
     if (repo == null)
         return null;
     var repoContent = repo.GetMod(x.Dependency);
     var mod = new ModRepoContent(x.Dependency, col.GameId, repoContent.Value.GetVersionInfo());
     if (repoContent.Value.Dependencies != null)
         mod.Dependencies = await GetDependencyTree(repoContent, customRepos, game).ConfigureAwait(false);
     return mod;
 }
 private async Task<Content> ConvertToGroupOrRepoContent(CollectionVersionDependencyModel x, Collection col,
     IReadOnlyCollection<CustomRepo> customRepos, IEnumerable<GroupContent> groupContent, Game game) {
     var gc =
         groupContent.FirstOrDefault(
             c => c.PackageName.Equals(x.Dependency, StringComparison.CurrentCultureIgnoreCase));
     if (gc != null)
         // TODO: dependencies etc
         return new ModNetworkGroupContent(gc.Id, gc.PackageName, gc.GameId, gc.Version);
     return await HandleRepoContent(x, col, customRepos, game).ConfigureAwait(false);
 }
 private async Task<ContentSpec> ProcessEmbeddedCollection(
     IEnumerable<CollectionModelWithLatestVersion> cols, CollectionVersionDependencyModel ec,
     List<NetworkCollection> collections, CancellationToken ct) {
     var rc = cols.First(c2 => c2.Id == ec.CollectionDependencyId.Value);
     var conv = await MapCollection(rc, ct, collections).ConfigureAwait(false);
     collections.Add(conv);
     return new ContentSpec(conv, ec.Constraint);
 }
 private async Task<ContentSpec> GetContentSpec(List<NetworkCollection> collections,
     CollectionVersionDependencyModel[] todoCols, CollectionVersionDependencyModel ec,
     IEnumerable<CollectionModelWithLatestVersion> cols, CancellationToken ct) {
     if (todoCols.Contains(ec)) {
         return
             await ProcessEmbeddedCollection(cols, ec, collections, ct).ConfigureAwait(false);
     }
     return new ContentSpec(collections.First(co => co.Id == ec.CollectionDependencyId.Value),
         ec.Constraint);
 }
 private async Task <ContentSpec> GetContentSpec(List <NetworkCollection> collections,
                                                 CollectionVersionDependencyModel[] todoCols, CollectionVersionDependencyModel ec,
                                                 IEnumerable <CollectionModelWithLatestVersion> cols, CancellationToken ct)
 {
     if (todoCols.Contains(ec))
     {
         return
             (await ProcessEmbeddedCollection(cols, ec, collections, ct).ConfigureAwait(false));
     }
     return(new ContentSpec(collections.First(co => co.Id == ec.CollectionDependencyId.Value),
                            ec.Constraint));
 }
 static Content ConvertToContentOrLocal(CollectionVersionDependencyModel x, Collection col,
     IEnumerable<NetworkContent> content) {
     return (Content) content.FirstOrDefault(
         cnt =>
             cnt.PackageName.Equals(x.Dependency,
                 StringComparison.CurrentCultureIgnoreCase))
            ?? new ModLocalContent(x.Dependency, x.Dependency.ToLower(), col.GameId, null);
 }
 static Content ConvertToRepoContent(CollectionVersionDependencyModel x, Collection col, CustomRepo[] customRepos,
     IReadOnlyCollection<NetworkContent> content) {
     var repo = customRepos.FirstOrDefault(r => r.HasMod(x.Dependency));
     if (repo == null)
         return null;
     var repoContent = repo.GetMod(x.Dependency);
     var mod = new ModRepoContent(x.Dependency, x.Dependency, col.GameId, repoContent.Value.ModVersion);
     if (repoContent.Value.Dependencies != null)
         mod.Dependencies = GetDependencyTree(repoContent, customRepos, content);
     return mod;
 }