コード例 #1
0
        public async Task Prepare()
        {
            if (!_prepared)
            {
                using var _ = await _lock.Wait();

                // Could have become prepared while we waited for the lock
                if (!_prepared)
                {
                    _client = await NexusApiClient.Get();

                    _status = await _client.GetUserStatus();

                    if (!_client.IsAuthenticated)
                    {
                        Utils.ErrorThrow(new UnconvertedError(
                                             $"Authenticating for the Nexus failed. A nexus account is required to automatically download mods."));
                        return;
                    }


                    if (!await _client.IsPremium())
                    {
                        var result = await Utils.Log(new YesNoIntervention(
                                                         "Wabbajack can operate without a premium account, but downloads will be slower and the install process will require more user interactions (you will have to start each download by hand). Are you sure you wish to continue?",
                                                         "Continue without Premium?")).Task;

                        if (result == ConfirmationIntervention.Choice.Abort)
                        {
                            Utils.ErrorThrow(new UnconvertedError($"Aborting at the request of the user"));
                        }
                        _prepared = true;
                    }
                }
            }
        }