コード例 #1
0
        public CliPatcherVm(
            IPatcherIdProvider idProvider,
            IPatcherNameVm nameVm,
            IPathToExecutableInputVm pathToExecutableInputVm,
            IProfileDisplayControllerVm selPatcher,
            IConfirmationPanelControllerVm confirmation,
            IShowHelpSetting showHelpSetting,
            ILifetimeScope scope,
            PatcherRenameActionVm.Factory renameFactory,
            CliPatcherSettings?settings = null)
            : base(scope, nameVm, selPatcher, confirmation, idProvider, renameFactory, settings)
        {
            ExecutableInput = pathToExecutableInputVm;
            ShowHelpSetting = showHelpSetting;

            _state = pathToExecutableInputVm.WhenAnyValue(x => x.Picker.ErrorState)
                     .Select(e =>
            {
                return(new ConfigurationState()
                {
                    IsHaltingError = !e.Succeeded,
                    RunnableState = e
                });
            })
                     .ToGuiProperty <ConfigurationState>(this, nameof(State), new ConfigurationState(ErrorResponse.Fail("Evaluating"))
            {
                IsHaltingError = false
            }, deferSubscription: true);
        }
コード例 #2
0
ファイル: PatcherVm.cs プロジェクト: sharpsteve/Synthesis
        public PatcherVm(
            ILifetimeScope scope,
            IPatcherNameVm nameVm,
            IProfileDisplayControllerVm selPatcher,
            IConfirmationPanelControllerVm confirmation,
            IPatcherIdProvider idProvider,
            PatcherRenameActionVm.Factory renameFactory,
            PatcherSettings?settings)
        {
            Scope = scope;
            Scope.DisposeWith(this);
            NameVm     = nameVm;
            InternalID = idProvider.InternalId;

            _isSelected = selPatcher.WhenAnyValue(x => x.SelectedObject)
                          .Select(x => x == this)
                          // Not GuiProperty, as it interacts with drag/drop oddly
                          .ToProperty(this, nameof(IsSelected));

            if (settings != null)
            {
                CopyInSettings(settings);
            }

            DeleteCommand = ReactiveCommand.Create(() =>
            {
                confirmation.TargetConfirmation = new ConfirmationActionVm(
                    "Confirm",
                    $"Are you sure you want to delete {NameVm.Name}?",
                    Delete);
            });

            RenameCommand = ReactiveCommand.Create(() =>
            {
                confirmation.TargetConfirmation = renameFactory();
            });

            ErrorDisplayVm = new ErrorDisplayVm(this, this.WhenAnyValue(x => x.State));
        }
コード例 #3
0
 public SelectedGroupControllerVm(
     IProfileGroupsList groupsList,
     IProfileDisplayControllerVm selected)
 {
     _selectedGroup = Observable.CombineLatest(
         selected.WhenAnyValue(x => x.SelectedObject),
         groupsList.Groups.Connect()
         .ObserveOnGui()
         .QueryWhenChanged(q => q),
         (selected, groups) => selected ?? groups.FirstOrDefault())
                      .Select(x =>
     {
         if (x is GroupVm group)
         {
             return(group);
         }
         if (x is PatcherVm patcher)
         {
             return(patcher.Group);
         }
         return(default(GroupVm?));
     })
                      .ToGuiProperty(this, nameof(SelectedGroup), default(GroupVm?), deferSubscription: true);
 }
コード例 #4
0
ファイル: GitPatcherVm.cs プロジェクト: sharpsteve/Synthesis
        public GitPatcherVm(
            IGithubPatcherIdentifier ident,
            IPatcherNameVm nameVm,
            IProfileDisplayControllerVm selPatcher,
            IConfirmationPanelControllerVm confirmation,
            ISelectedProjectInputVm selectedProjectInput,
            IGitRemoteRepoPathInputVm remoteRepoPathInputVm,
            INavigateTo navigate,
            IAvailableTags availableTags,
            ILockToCurrentVersioning lockToCurrentVersioning,
            IAvailableProjects availableProjects,
            ICompilationProvider compilationProvider,
            IBaseRepoDirectoryProvider baseRepoDir,
            IGitStatusDisplay gitStatusDisplay,
            IDriverRepoDirectoryProvider driverRepoDirectoryProvider,
            IRunnerRepoDirectoryProvider runnerRepoDirectoryProvider,
            IGetRepoPathValidity getRepoPathValidity,
            IRepoClonesValidStateVm repoClonesValid,
            INugetDiffProviderVm nugetDiff,
            IGitPatcherState state,
            ILogger logger,
            IRunnableStateProvider runnableStateProvider,
            ILifetimeScope scope,
            IGitPatcherTargetingVm patcherTargeting,
            ICheckoutInputProvider checkoutInputProvider,
            IGitNugetTargetingVm nugetTargetingVm,
            IUpdateAllCommand updateAllCommand,
            IAttemptedCheckout attemptedCheckout,
            IPatcherIdProvider idProvider,
            ICopyOverExtraData copyOverExtraData,
            PatcherRenameActionVm.Factory renameFactory,
            DeleteUserData deleteUserData,
            PatcherUserSettingsVm.Factory settingsVmFactory,
            GithubPatcherSettings?settings = null)
            : base(
                scope, nameVm, selPatcher,
                confirmation, idProvider, renameFactory, settings)
        {
            _logger              = logger;
            _copyOverExtraData   = copyOverExtraData;
            SelectedProjectInput = selectedProjectInput;
            RemoteRepoPathInput  = remoteRepoPathInputVm;
            Locking              = lockToCurrentVersioning;
            RepoClonesValid      = repoClonesValid;
            NugetDiff            = nugetDiff;
            PatcherTargeting     = patcherTargeting;
            NugetTargeting       = nugetTargetingVm;
            UpdateAllCommand     = updateAllCommand;

            DeleteUserDataCommand = ReactiveCommand.Create(deleteUserData.Delete);

            ID = ident.Id;

            CopyInSettings(settings);

            LocalDriverRepoDirectory = driverRepoDirectoryProvider.Path.Path;
            LocalRunnerRepoDirectory = runnerRepoDirectoryProvider.Path.Path;

            _repoValidity = getRepoPathValidity.RepoPath
                            .Select(r => r.RunnableState)
                            .ToGuiProperty(this, nameof(RepoValidity), deferSubscription: true);

            AvailableProjects = availableProjects.Projects;

            AvailableTags = availableTags.Tags;

            _attemptedCheckout = checkoutInputProvider.Input
                                 .Select(attemptedCheckout.Attempted)
                                 .ToGuiProperty(this, nameof(AttemptedCheckout), deferSubscription: true);

            _runnableData = runnableStateProvider.WhenAnyValue(x => x.State.Item)
                            .ToGuiProperty(this, nameof(RunnableData), default(RunnerRepoInfo?), deferSubscription: true);

            _state = state.State
                     .ToGuiProperty(this, nameof(State), new ConfigurationState(ErrorResponse.Fail("Evaluating"))
            {
                IsHaltingError = false
            }, deferSubscription: true);

            OpenGitPageCommand = ReactiveCommand.Create(
                canExecute: this.WhenAnyValue(x => x.RepoValidity)
                .Select(x => x.Succeeded),
                execute: () => navigate.Navigate(RemoteRepoPathInput.RemoteRepoPath));

            OpenGitPageToVersionCommand = ReactiveCommand.Create(
                canExecute: this.WhenAnyFallback(x => x.RunnableData)
                .Select(x => x != null),
                execute: () =>
            {
                try
                {
                    if (RunnableData is not {
                    } runnable)
                    {
                        return;
                    }
                    navigate.Navigate(Path.Combine(RemoteRepoPathInput.RemoteRepoPath, "tree", runnable.Target.Target));
                }
                catch (Exception ex)
                {
                    _logger.Error(ex, "Error opening Git webpage");
                }
            });

            NavigateToInternalFilesCommand = ReactiveCommand.Create(() => navigate.Navigate(baseRepoDir.Path));

            PatcherSettings = settingsVmFactory(
                false,
                compilationProvider.State.Select(c =>
            {
                if (c.RunnableState.Failed)
                {
                    return(new PatcherUserSettingsVm.Inputs(c.RunnableState.BubbleFailure <FilePath>(), null, default));
                }
                return(new PatcherUserSettingsVm.Inputs(GetResponse <FilePath> .Succeed(c.Item.ProjPath), c.Item.TargetVersions.Synthesis, c.Item.MetaPath));
            })
                .DistinctUntilChanged())
                              .DisposeWith(this);

            _statusDisplay = gitStatusDisplay.StatusDisplay
                             .ToGuiProperty(this, nameof(StatusDisplay),
                                            new StatusRecord(
                                                Text: "Initializing",
                                                Processing: false,
                                                Blocking: false,
                                                Command: null), deferSubscription: true);

            SetToLastSuccessfulRunCommand = ReactiveCommand.Create(
                canExecute: this.WhenAnyValue(x => x.LastSuccessfulRun)
                .Select(x =>
            {
                return(x != null &&
                       !x.TargetRepo.IsNullOrWhitespace() &&
                       !x.ProjectSubpath.IsNullOrWhitespace() &&
                       !x.Commit.IsNullOrWhitespace() &&
                       !x.MutagenVersion.IsNullOrWhitespace() &&
                       !x.SynthesisVersion.IsNullOrWhitespace());
            }),
                execute: () =>
            {
                if (LastSuccessfulRun == null)
                {
                    return;
                }
                RemoteRepoPathInput.RemoteRepoPath         = LastSuccessfulRun.TargetRepo;
                this.SelectedProjectInput.ProjectSubpath   = LastSuccessfulRun.ProjectSubpath;
                this.PatcherTargeting.TargetCommit         = LastSuccessfulRun.Commit;
                this.NugetTargeting.ManualMutagenVersion   = LastSuccessfulRun.MutagenVersion;
                this.NugetTargeting.ManualSynthesisVersion = LastSuccessfulRun.SynthesisVersion;
                this.PatcherTargeting.PatcherVersioning    = PatcherVersioningEnum.Commit;
                this.NugetTargeting.SynthesisVersioning    = PatcherNugetVersioningEnum.Manual;
                this.NugetTargeting.MutagenVersioning      = PatcherNugetVersioningEnum.Manual;
            });
        }
コード例 #5
0
ファイル: ProfileVm.cs プロジェクト: sharpsteve/Synthesis
        public ProfileVm(
            ILifetimeScope scope,
            IPatcherInitializationVm initVm,
            IProfileDataFolderVm dataFolder,
            IProfileIdentifier ident,
            IProfileNameVm nameProvider,
            IProfileLoadOrder loadOrder,
            IProfileDirectories dirs,
            IProfileVersioning versioning,
            IProfileDisplayControllerVm profileDisplay,
            ILockToCurrentVersioning lockSetting,
            ISelectedProfileControllerVm selProfile,
            IProfileExporter exporter,
            IProfileGroupsList groupsList,
            IEnvironmentErrorsVm environmentErrors,
            OverallErrorVm overallErrorVm,
            StartRun startRun,
            ILogger logger)
        {
            Scope              = scope;
            Init               = initVm;
            OverallErrorVm     = overallErrorVm;
            NameVm             = nameProvider;
            Groups             = groupsList.Groups;
            DataFolderOverride = dataFolder;
            Versioning         = versioning;
            LockSetting        = lockSetting;
            Exporter           = exporter;
            DisplayController  = profileDisplay;
            _startRun          = startRun;
            _logger            = logger;
            ID      = ident.ID;
            Release = ident.Release;

            GroupsDisplay = new SourceListUiFunnel <GroupVm>(Groups, this);

            ProfileDirectory = dirs.ProfileDirectory;
            WorkingDirectory = dirs.WorkingDirectory;

            EnvironmentErrors = environmentErrors;

            _dataFolder = dataFolder.WhenAnyValue(x => x.Path)
                          .ToGuiProperty <DirectoryPath>(this, nameof(DataFolder), string.Empty, deferSubscription: true);

            LoadOrder = loadOrder.LoadOrder;

            var enabledGroups = Groups.Connect()
                                .ObserveOnGui()
                                .FilterOnObservable(p => p.WhenAnyValue(x => x.IsOn), scheduler: RxApp.MainThreadScheduler)
                                .RefCount();

            var enabledGroupModKeys = enabledGroups
                                      .Transform(x => x.ModKey)
                                      .QueryWhenChanged(q => q.ToHashSet())
                                      .Replay(1).RefCount();

            _blockingError = Observable.CombineLatest(
                dataFolder.WhenAnyValue(x => x.DataFolderResult),
                loadOrder.WhenAnyValue(x => x.State),
                enabledGroups
                .QueryWhenChanged(q => q)
                .StartWith(Noggog.ListExt.Empty <GroupVm>()),
                enabledGroups
                .FilterOnObservable(g => g.WhenAnyValue(x => x.State).Select(x => x.IsHaltingError))
                .QueryWhenChanged(q => q)
                .StartWith(Noggog.ListExt.Empty <GroupVm>()),
                LoadOrder.Connect()
                .FilterOnObservable(
                    x =>
            {
                return(Observable.CombineLatest(
                           x.WhenAnyValue(y => y.Exists)
                           .DistinctUntilChanged(),
                           enabledGroupModKeys
                           .Select(groupModKeys => groupModKeys.Contains(x.ModKey)),
                           (exists, isEnabledGroupKey) => !exists && !isEnabledGroupKey));
            },
                    scheduler: RxApp.MainThreadScheduler)
                .QueryWhenChanged(q => q)
                .StartWith(Noggog.ListExt.Empty <ReadOnlyModListingVM>())
                .Throttle(TimeSpan.FromMilliseconds(200), RxApp.MainThreadScheduler),
                this.WhenAnyValue(x => x.IgnoreMissingMods),
                (dataFolder, loadOrder, enabledGroups, erroredEnabledGroups, missingMods, ignoreMissingMods) =>
            {
                if (enabledGroups.Count == 0)
                {
                    return(GetResponse <ViewModel> .Fail("There are no enabled groups to run."));
                }
                if (!dataFolder.Succeeded)
                {
                    return(dataFolder.BubbleFailure <ViewModel>());
                }
                if (!loadOrder.Succeeded)
                {
                    return(loadOrder.BubbleFailure <ViewModel>());
                }
                if (!ignoreMissingMods && missingMods.Count > 0)
                {
                    return(GetResponse <ViewModel> .Fail($"Load order had mods that were missing:{Environment.NewLine}{string.Join(Environment.NewLine, missingMods.Select(x => x.ModKey))}"));
                }
                if (erroredEnabledGroups.Count > 0)
                {
                    var errGroup = erroredEnabledGroups.First();
                    return(GetResponse <ViewModel> .Fail(errGroup, $"\"{errGroup.Name}\" has a blocking error: {errGroup.State}"));
                }
                return(GetResponse <ViewModel> .Succeed(null !));
            })
コード例 #6
0
 public OverallErrorVm(IProfileDisplayControllerVm displayControllerVm)
     : base("Overall Blocking Error")
 {
     DisplayController = displayControllerVm;
 }
コード例 #7
0
        public PatcherInitializationVm(
            ILifetimeScope scope,
            IProfileGroupsList groupsList,
            INewGroupCreator groupCreator,
            ISelectedGroupControllerVm selectedGroupControllerVm,
            IProfileDisplayControllerVm displayControllerVm,
            PatcherInitRenameValidator renamer)
        {
            _scope = scope;
            _selectedGroupControllerVm = selectedGroupControllerVm;
            _displayControllerVm       = displayControllerVm;

            var hasAnyGroups = groupsList.Groups.CountChanged
                               .Select(x => x > 0)
                               .Replay(1)
                               .RefCount();

            AddGitPatcherCommand = ReactiveCommand.Create(
                () => { NewPatcher = Resolve <GitPatcherInitVm, GuiGitPatcherModule, GithubPatcherSettings>(); },
                canExecute: hasAnyGroups);
            AddSolutionPatcherCommand = ReactiveCommand.Create(
                () => { NewPatcher = Resolve <SolutionPatcherInitVm, GuiSolutionPatcherModule, SolutionPatcherSettings>(); },
                hasAnyGroups);
            AddCliPatcherCommand = ReactiveCommand.Create(
                () => { NewPatcher = Resolve <CliPatcherInitVm, GuiCliPatcherModule, CliPatcherSettings>(); },
                hasAnyGroups);
            AddGroupCommand = ReactiveCommand.Create(() =>
            {
                var group = groupCreator.Get();
                groupsList.Groups.Add(group);
                displayControllerVm.SelectedObject = group;
            });
            CompleteConfiguration = ReactiveCommand.CreateFromTask(
                async() =>
            {
                var initializer = this.NewPatcher;
                if (initializer == null)
                {
                    return;
                }
                var list = await initializer.Construct().ToListAsync().ConfigureAwait(false);
                foreach (var item in list)
                {
                    if (!await renamer.ConfirmNameUnique(item))
                    {
                        return;
                    }
                }
                AddNewPatchers(list);
            },
                canExecute: this.WhenAnyValue(x => x.NewPatcher)
                .Select(patcher =>
            {
                if (patcher == null)
                {
                    return(Observable.Return(false));
                }
                return(patcher.WhenAnyValue(x => x.CanCompleteConfiguration)
                       .Select(e => e.Succeeded)
                       .CombineLatest(
                           _selectedGroupControllerVm.WhenAnyValue(x => x.SelectedGroup)
                           .Select(x => x != null),
                           (canComplete, groupExists) => canComplete && groupExists));
            })
                .Switch());

            CancelConfiguration = ReactiveCommand.Create(
                () =>
            {
                NewPatcher?.Cancel();
                NewPatcher = null;
            });

            // Dispose any old patcher initializations
            this.WhenAnyValue(x => x.NewPatcher)
            .DisposePrevious()
            .Subscribe()
            .DisposeWith(this);
        }