public DotNetNotInstalledVm(IInstalledSdkFollower mvm, INavigateTo navigate) { _InError = mvm.DotNetSdkInstalled .Select(x => !x.Acceptable) .ToGuiProperty(this, nameof(InError), deferSubscription: true); _CustomDisplayString = mvm.DotNetSdkInstalled .Select(x => { if (x.Acceptable) { return(string.Empty); } if (x.Version.IsNullOrWhitespace()) { return("While the app can open with the DotNet Runtime, it also needs the SDK to be able to function."); } else { return($"While an SDK was found, it was not an acceptable version. You had {x.Version}, but it must be at least {ParseNugetVersionString.MinVersion}"); } }) .ToGuiProperty(this, nameof(CustomDisplayString), string.Empty, deferSubscription: true); DownloadCommand = ReactiveCommand.Create( () => { navigate.Navigate("https://dotnet.microsoft.com/download"); }); _ErrorString = this.WhenAnyValue(x => x.InError) .Select(x => x ? $"DotNet SDK: Desired SDK not found" : null) .ToGuiProperty(this, nameof(ErrorString), default, deferSubscription: true);
public NewestLibraryVersionsVm( ILogger logger, IQueryNewestLibraryVersions queryNewest, IInstalledSdkFollower installedSdkFollower) { _versions = Observable.Return(Unit.Default) .ObserveOn(TaskPoolScheduler.Default) .CombineLatest( installedSdkFollower.DotNetSdkInstalled, (_, DotNetVersions) => DotNetVersions) .SelectTask(async x => { try { if (!x.Acceptable) { logger.Error( "Can not query for latest nuget versions as there is no acceptable dotnet SDK installed"); return(new NugetVersionOptions( new NugetVersionPair(null, null), new NugetVersionPair(null, null))); } return(await queryNewest.GetLatestVersions(CancellationToken.None).ConfigureAwait(false)); } catch (Exception e) { logger.Error(e, "Error querying for versions"); return(new NugetVersionOptions( new NugetVersionPair(null, null), new NugetVersionPair(null, null))); } }) .ToGuiProperty(this, nameof(Versions), new NugetVersionOptions( new NugetVersionPair(null, null), new NugetVersionPair(null, null)), deferSubscription: true); }
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(); }