コード例 #1
0
            private async Task MapExistingCollection(CollectionModelWithLatestVersion rc,
                                                     SubscribedCollection collection, CancellationToken ct)
            {
                var userId = await _collectionInfoFetcher.GetUserId().ConfigureAwait(false);

                var conv = rc.MapTo(collection, opts => opts.Items["user-id"] = userId);

                // TODO: Allow parent repos to be used for children etc? :-)
                await HandleContent(conv, rc, ct).ConfigureAwait(false);

                conv.UpdateState();
            }
コード例 #2
0
            private async Task <SubscribedCollection> MapCollection(CollectionModelWithLatestVersion rc,
                                                                    CancellationToken ct, List <NetworkCollection> collections = null)
            {
                var userId = await _collectionInfoFetcher.GetUserId().ConfigureAwait(false);

                var conv = rc.MapTo <SubscribedCollection>(opts => opts.Items["user-id"] = userId);

                // TODO: Allow parent repos to be used for children etc? :-)
                await HandleContent(conv, rc, ct, collections).ConfigureAwait(false);

                conv.UpdateState();
                return(conv);
            }
コード例 #3
0
            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 _collectionInfoFetcher.GetGame(col.GameId).ConfigureAwait(false))
                    .ConfigureAwait(false);

                col.ReplaceContent(modSpecs.Concat(collectionSpecs));
            }
コード例 #4
0
            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());
            }
コード例 #5
0
 private async Task<SubscribedCollection> MapCollection(CollectionModelWithLatestVersion rc,
     CancellationToken ct, List<NetworkCollection> collections = null) {
     var userId = await GetUserId().ConfigureAwait(false);
     var conv = rc.MapTo<SubscribedCollection>(opts => opts.Items["user-id"] = userId);
     // TODO: Allow parent repos to be used for children etc? :-)
     await HandleContent(conv, rc, ct, collections).ConfigureAwait(false);
     conv.UpdateState();
     return conv;
 }
コード例 #6
0
 private async Task MapExistingCollection(CollectionModelWithLatestVersion rc,
     SubscribedCollection collection, CancellationToken ct) {
     var userId = await GetUserId().ConfigureAwait(false);
     var conv = rc.MapTo(collection, opts => opts.Items["user-id"] = userId);
     // TODO: Allow parent repos to be used for children etc? :-)
     await HandleContent(conv, rc, ct).ConfigureAwait(false);
     conv.UpdateState();
 }
コード例 #7
0
            private async Task<IEnumerable<ContentSpec>> ProcessEmbeddedCollections(CollectionModelWithLatestVersion c,
                List<NetworkCollection> collections, CancellationToken ct) {
                var embeddedCollections =
                    c.LatestVersion.Dependencies.Where(x => x.DependencyType == DependencyType.Collection).ToArray();
                if (!embeddedCollections.Any())
                    return Enumerable.Empty<ContentSpec>();

                var todoCols =
                    embeddedCollections.Where(x => collections.All(co => co.Id != x.CollectionDependencyId.Value))
                        .ToArray();
                var cols = await
                    RetrieveCollections(c.GameId, todoCols.Select(x => x.CollectionDependencyId.Value), ct)
                        .ConfigureAwait(false);

                var buildCollections = new List<ContentSpec>();
                foreach (var ec in embeddedCollections) {
                    var contentSpec =
                        await GetContentSpec(collections, todoCols, ec, cols, ct).ConfigureAwait(false);
                    buildCollections.Add(contentSpec);
                }
                return buildCollections;
            }
コード例 #8
0
            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();
            }
コード例 #9
0
 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));
 }
コード例 #10
0
            private async Task <IEnumerable <ContentSpec> > ProcessEmbeddedCollections(CollectionModelWithLatestVersion c,
                                                                                       List <NetworkCollection> collections, CancellationToken ct)
            {
                var embeddedCollections =
                    c.LatestVersion.Dependencies.Where(x => x.DependencyType == DependencyType.Collection).ToArray();

                if (!embeddedCollections.Any())
                {
                    return(Enumerable.Empty <ContentSpec>());
                }

                var todoCols =
                    embeddedCollections.Where(x => collections.All(co => co.Id != x.CollectionDependencyId.Value))
                    .ToArray();
                var cols = await
                           RetrieveCollections(c.GameId, todoCols.Select(x => x.CollectionDependencyId.Value), ct)
                           .ConfigureAwait(false);

                var buildCollections = new List <ContentSpec>();

                foreach (var ec in embeddedCollections)
                {
                    var contentSpec =
                        await GetContentSpec(collections, todoCols, ec, cols, ct).ConfigureAwait(false);

                    buildCollections.Add(contentSpec);
                }
                return(buildCollections);
            }
コード例 #11
0
 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());
 }