Exemplo n.º 1
0
        public async Task ImportFromStableAsync(StableContent content)
        {
            var stableStorage = await getStableStorage().ConfigureAwait(false);

            var importTasks = new List <Task>();

            Task beatmapImportTask = Task.CompletedTask;

            if (content.HasFlagFast(StableContent.Beatmaps))
            {
                importTasks.Add(beatmapImportTask = new LegacyBeatmapImporter(beatmaps).ImportFromStableAsync(stableStorage));
            }

            if (content.HasFlagFast(StableContent.Skins))
            {
                importTasks.Add(new LegacySkinImporter(skins).ImportFromStableAsync(stableStorage));
            }

            if (content.HasFlagFast(StableContent.Collections))
            {
                importTasks.Add(beatmapImportTask.ContinueWith(_ => collections.ImportFromStableAsync(stableStorage), TaskContinuationOptions.OnlyOnRanToCompletion));
            }

            if (content.HasFlagFast(StableContent.Scores))
            {
                importTasks.Add(beatmapImportTask.ContinueWith(_ => new LegacyScoreImporter(scores).ImportFromStableAsync(stableStorage), TaskContinuationOptions.OnlyOnRanToCompletion));
            }

            await Task.WhenAll(importTasks.ToArray()).ConfigureAwait(false);
        }
Exemplo n.º 2
0
        public async Task ImportFromStableAsync(StableContent content, bool interactiveLocateIfNotFound = true)
        {
            var stableStorage = GetCurrentStableStorage();

            if (stableStorage == null)
            {
                if (!interactiveLocateIfNotFound)
                {
                    return;
                }

                var taskCompletionSource = new TaskCompletionSource <string>(TaskCreationOptions.RunContinuationsAsynchronously);
                Schedule(() => dialogOverlay.Push(new StableDirectoryLocationDialog(taskCompletionSource)));
                string stablePath = await taskCompletionSource.Task.ConfigureAwait(false);

                UpdateStorage(stablePath);
                stableStorage = GetCurrentStableStorage();
            }

            var importTasks = new List <Task>();

            Task beatmapImportTask = Task.CompletedTask;

            if (content.HasFlagFast(StableContent.Beatmaps))
            {
                importTasks.Add(beatmapImportTask = new LegacyBeatmapImporter(beatmaps).ImportFromStableAsync(stableStorage));
            }

            if (content.HasFlagFast(StableContent.Skins))
            {
                importTasks.Add(new LegacySkinImporter(skins).ImportFromStableAsync(stableStorage));
            }

            if (content.HasFlagFast(StableContent.Collections))
            {
                importTasks.Add(beatmapImportTask.ContinueWith(_ => collections.ImportFromStableAsync(stableStorage), TaskContinuationOptions.OnlyOnRanToCompletion));
            }

            if (content.HasFlagFast(StableContent.Scores))
            {
                importTasks.Add(beatmapImportTask.ContinueWith(_ => new LegacyScoreImporter(scores).ImportFromStableAsync(stableStorage), TaskContinuationOptions.OnlyOnRanToCompletion));
            }

            await Task.WhenAll(importTasks.ToArray()).ConfigureAwait(false);
        }