コード例 #1
0
        /// <summary>
        /// Upload any resources that have been collected to the collection.
        /// </summary>
        /// <param name="environment">The environment to load from</param>
        /// <param name="collector">The collector that gathered the resources</param>
        /// <returns>Completion task</returns>
        public async Task Upload(IEnvironment environment, ResourceCollector collector)
        {
            if (environment?.ID == null)
            {
                return;
            }
            EnsureEnvironment(environment);

            var rlist = _resources[environment.ID];
            var tlist = _textures[environment.ID];

            var textures = collector.Textures.Except(tlist, StringComparer.InvariantCultureIgnoreCase).ToHashSet();

            if (textures.Any())
            {
                var tc = await environment.GetTextureCollection();

                var items = await tc.GetTextureItems(textures);

                using (var ss = tc.GetStreamSource())
                {
                    // ReSharper disable once AccessToDisposedClosure : We know this closure completes before `ss` is disposed due to Task.WaitAll
                    var tasks = items.Select(x => Task.Run(() => UploadTexture(environment, x, ss))).ToList();
                    await Task.WhenAll(tasks);

                    rlist.AddRange(tasks.Select(x => x.Result));
                    tlist.UnionWith(textures);
                }
            }
        }
コード例 #2
0
 public void Merge(ResourceCollector collector)
 {
     Textures.UnionWith(collector.Textures);
     AddedRenderables.UnionWith(collector.AddedRenderables);
     RemovedRenderables.UnionWith(collector.RemovedRenderables);
 }