public RepoClonesValidStateVm(
     IDriverRepositoryPreparationFollower driverRepositoryPreparation,
     IRunnerRepositoryPreparation runnerRepositoryPreparation)
 {
     _Valid = Observable.CombineLatest(
         driverRepositoryPreparation.DriverInfo,
         runnerRepositoryPreparation.State,
         (driver, runner) => driver.RunnableState.Succeeded && runner.RunnableState.Succeeded)
              .ToGuiProperty(this, nameof(Valid), deferSubscription: true);
 }
Exemplo n.º 2
0
 public CheckoutInputProvider(
     IRunnerRepositoryPreparation runnerRepositoryState,
     ISelectedProjectInputVm selectedProjectInput,
     IPatcherVersioningFollower patcherTargeting,
     INugetVersioningFollower nugetTargeting)
 {
     Input = Observable.CombineLatest(
         runnerRepositoryState.State,
         selectedProjectInput.Picker.PathState()
         .Select(x => x.Succeeded ? x : GetResponse <string> .Fail("No patcher project selected.")),
         patcherTargeting.ActivePatcherVersion,
         nugetTargeting.ActiveNugetVersion,
         (runnerState, proj, patcherVersioning, libraryNugets) => new PotentialCheckoutInput(
             runnerState,
             proj,
             patcherVersioning,
             libraryNugets))
             .Replay(1)
             .RefCount();
 }
Exemplo n.º 3
0
        public GitPatcherState(
            IDriverRepositoryPreparationFollower driverRepositoryPreparation,
            IRunnerRepositoryPreparation runnerRepositoryState,
            IRunnableStateProvider runnableStateProvider,
            IPatcherRunnabilityCliState runnabilityCliState,
            IInstalledSdkFollower dotNetInstalled,
            IEnvironmentErrorsVm envErrors,
            IMissingMods missingMods,
            ILogger logger)
        {
            State = Observable.CombineLatest(
                driverRepositoryPreparation.DriverInfo
                .Select(x => x.ToUnit()),
                runnerRepositoryState.State,
                runnableStateProvider.WhenAnyValue(x => x.State)
                .Select(x => x.ToUnit()),
                runnabilityCliState.Runnable,
                dotNetInstalled.DotNetSdkInstalled
                .Select(x => (x, true))
                .StartWith((new DotNetVersion(string.Empty, false), false)),
                envErrors.WhenAnyFallback(x => x.ActiveError !.ErrorString),
                missingMods.Missing
                .QueryWhenChanged()
                .Throttle(TimeSpan.FromMilliseconds(200), RxApp.MainThreadScheduler)
                .StartWith(ListExt.Empty <ModKey>()),
                (driver, runner, checkout, runnability, dotnet, envError, reqModsMissing) =>
            {
                if (driver.IsHaltingError)
                {
                    return(driver);
                }
                if (runner.IsHaltingError)
                {
                    return(runner);
                }
                if (!dotnet.Item2)
                {
                    return(new ConfigurationState(ErrorResponse.Fail("Determining DotNet SDK installed"))
                    {
                        IsHaltingError = false
                    });
                }

                if (!dotnet.Item1.Acceptable)
                {
                    return(new ConfigurationState(ErrorResponse.Fail("No DotNet SDK installed")));
                }
                if (envError != null)
                {
                    return(new ConfigurationState(ErrorResponse.Fail(envError)));
                }

                if (reqModsMissing.Count > 0)
                {
                    return(new ConfigurationState(ErrorResponse.Fail(
                                                      $"Required mods missing from load order:{Environment.NewLine}{string.Join(Environment.NewLine, reqModsMissing)}")));
                }

                if (runnability.RunnableState.Failed)
                {
                    return(runnability.BubbleError());
                }

                if (checkout.RunnableState.Failed)
                {
                    return(checkout.BubbleError());
                }

                logger.Information("State returned success!");
                return(ConfigurationState.Success);
            })
                    .Replay(1)
                    .RefCount();
        }