예제 #1
0
파일: GuiLoader.cs 프로젝트: Zelfrom/Mtgdb
        [UsedImplicitly]         // by ninject
        public GuiLoader(
            Loader loader,
            CardRepository repo,
            CardRepository42 repo42,
            CardRepositoryLegacy repoLegacy,
            NewsService newsService,
            DownloaderSubsystem downloaderSubsystem,
            DeckListModel deckListModel,
            DeckListLegacyConverter deckListConverter,
            HistoryLegacyConverter historyConverter,
            DeckSearcher deckSearcher)
        {
            _loader            = loader;
            _repo              = repo;
            _repo42            = repo42;
            _repoLegacy        = repoLegacy;
            _deckListConverter = deckListConverter;
            _historyConverter  = historyConverter;

            _loader.AddAction(newsService.FetchNews);
            _loader.AddAction(downloaderSubsystem.CalculateProgress);
            _loader.AddTask(async() =>
            {
                if (deckListConverter.IsLegacyConversionRequired)
                {
                    while (!deckListConverter.IsConversionCompleted)
                    {
                        await TaskEx.Delay(100);
                    }
                }

                deckListModel.Load();

                if (deckSearcher.IsIndexSaved)
                {
                    deckSearcher.LoadIndexes();
                }
                else
                {
                    while (!_repo.IsPriceLoadingComplete)
                    {
                        await TaskEx.Delay(100);
                    }

                    deckSearcher.LoadIndexes();
                }
            });
        }