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; }
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 void HandleContent(IReadOnlyCollection<NetworkContent> content, Collection col, CollectionModelWithLatestVersion c, CustomRepo[] customRepos) { col.Contents.Replace( c.LatestVersion .Dependencies .Select( x => new { Content = ConvertToRepoContent(x, col, customRepos, content) ?? ConvertToContentOrLocal(x, col, content), // temporary x.Constraint }) .Where(x => x.Content != null) .Select(x => new ContentSpec(x.Content, x.Constraint)) .ToList()); }