public async Task Handle(IUserIntervention msg)
        {
            switch (msg)
            {
            case RequestNexusAuthorization c:
                await WrapBrowserJob(msg, async (vm, cancel) =>
                {
                    var key = await NexusApiClient.SetupNexusLogin(vm.Browser, m => vm.Instructions = m, cancel.Token);
                    c.Resume(key);
                });

                break;

            case RequestLoversLabLogin c:
                await WrapBrowserJob(msg, async (vm, cancel) =>
                {
                    var data = await LoversLabDownloader.GetAndCacheLoversLabCookies(vm.Browser, m => vm.Instructions = m, cancel.Token);
                    c.Resume(data);
                });

                break;

            case ConfirmationIntervention c:
                break;

            default:
                throw new NotImplementedException($"No handler for {msg}");
            }
        }
Exemple #2
0
        public async Task Handle(IUserIntervention msg)
        {
            switch (msg)
            {
            case RequestNexusAuthorization c:
                await WrapBrowserJob(msg, async (vm, cancel) =>
                {
                    await vm.Driver.WaitForInitialized();
                    var key = await NexusApiClient.SetupNexusLogin(new CefSharpWrapper(vm.Browser), m => vm.Instructions = m, cancel.Token);
                    c.Resume(key);
                });

                break;

            case RequestBethesdaNetLogin c:
                var data = await BethesdaNetDownloader.Login();

                c.Resume(data);
                break;

            case AbstractNeedsLoginDownloader.RequestSiteLogin c:
                await WrapBrowserJob(msg, async (vm, cancel) =>
                {
                    await vm.Driver.WaitForInitialized();
                    var data = await c.Downloader.GetAndCacheCookies(new CefSharpWrapper(vm.Browser), m => vm.Instructions = m, cancel.Token);
                    c.Resume(data);
                });

                break;

            case YesNoIntervention c:
                var result = MessageBox.Show(c.ExtendedDescription, c.ShortDescription, MessageBoxButton.YesNo,
                                             MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    c.Confirm();
                }
                else
                {
                    c.Cancel();
                }
                break;

            case CriticalFailureIntervention c:
                MessageBox.Show(c.ExtendedDescription, c.ShortDescription, MessageBoxButton.OK,
                                MessageBoxImage.Error);
                c.Cancel();
                break;

            case ConfirmationIntervention c:
                break;

            default:
                throw new NotImplementedException($"No handler for {msg}");
            }
        }