Beispiel #1
0
        public ProfileVersioning(
            ILogger logger,
            IProfileNameProvider nameProvider,
            INewestProfileLibraryVersionsVm libs)
        {
            ActiveVersioning = Observable.CombineLatest(
                this.WhenAnyValue(x => x.MutagenVersioning),
                this.WhenAnyValue(x => x.ManualMutagenVersion),
                libs.WhenAnyValue(x => x.NewestMutagenVersion),
                this.WhenAnyValue(x => x.SynthesisVersioning),
                this.WhenAnyValue(x => x.ManualSynthesisVersion),
                libs.WhenAnyValue(x => x.NewestSynthesisVersion),
                (mutaVersioning, mutaManual, newestMuta, synthVersioning, synthManual, newestSynth) =>
            {
                return(new ActiveNugetVersioning(
                           new NugetsToUse("Mutagen", mutaVersioning, mutaManual ?? newestMuta ?? string.Empty, newestMuta),
                           new NugetsToUse("Synthesis", synthVersioning, synthManual ?? newestSynth ?? string.Empty, newestSynth)));
            })
                               .Do(x => logger.Information("Swapped profile {Nickname} to {Versioning}", nameProvider.Name, x))
                               .ObserveOnGui()
                               .Replay(1)
                               .RefCount();

            // Set manual if empty
            libs.WhenAnyValue(x => x.NewestMutagenVersion)
            .Subscribe(x =>
            {
                if (ManualMutagenVersion == null)
                {
                    ManualMutagenVersion = x;
                }
            })
            .DisposeWith(this);
            libs.WhenAnyValue(x => x.NewestSynthesisVersion)
            .Subscribe(x =>
            {
                if (ManualSynthesisVersion == null)
                {
                    ManualSynthesisVersion = x;
                }
            })
            .DisposeWith(this);

            UpdateMutagenManualToLatestCommand = NoggogCommand.CreateFromObject(
                objectSource: libs.WhenAnyValue(x => x.NewestMutagenVersion)
                .ObserveOnGui(),
                canExecute: v =>
            {
                return(Observable.CombineLatest(
                           this.WhenAnyValue(x => x.MutagenVersioning),
                           this.WhenAnyValue(x => x.ManualMutagenVersion),
                           v,
                           (versioning, manual, latest) =>
                {
                    if (versioning != NugetVersioningEnum.Manual)
                    {
                        return false;
                    }
                    return latest != null && latest != manual;
                })
                       .ObserveOnGui());
            },
                execute: v => ManualMutagenVersion = v ?? string.Empty,
                disposable: this);
            UpdateSynthesisManualToLatestCommand = NoggogCommand.CreateFromObject(
                objectSource: libs.WhenAnyValue(x => x.NewestSynthesisVersion)
                .ObserveOnGui(),
                canExecute: v =>
            {
                return(Observable.CombineLatest(
                           this.WhenAnyValue(x => x.SynthesisVersioning),
                           this.WhenAnyValue(x => x.ManualSynthesisVersion),
                           v,
                           (versioning, manual, latest) =>
                {
                    if (versioning != NugetVersioningEnum.Manual)
                    {
                        return false;
                    }
                    return latest != null && latest != manual;
                })
                       .ObserveOnGui());
            },
                execute: v => ManualSynthesisVersion = v ?? string.Empty,
                disposable: this);

            UpdateProfileNugetVersionCommand = CommandExt.CreateCombinedAny(
                this.UpdateMutagenManualToLatestCommand,
                this.UpdateSynthesisManualToLatestCommand);
        }
Beispiel #2
0
        public GitNugetTargetingVm(
            ILogger logger,
            INewestProfileLibraryVersionsVm newest,
            IProfileVersioning versioning)
        {
            UpdateMutagenManualToLatestCommand = NoggogCommand.CreateFromObject(
                objectSource: newest.WhenAnyValue(x => x.NewestMutagenVersion),
                canExecute: v =>
            {
                return(Observable.CombineLatest(
                           this.WhenAnyValue(x => x.ManualMutagenVersion),
                           v,
                           (manual, latest) => latest != null && latest != manual));
            },
                execute: v => ManualMutagenVersion = v ?? string.Empty,
                extraCanExecute: this.WhenAnyValue(x => x.MutagenVersioning)
                .Select(vers => vers == PatcherNugetVersioningEnum.Manual),
                disposable: this);
            UpdateSynthesisManualToLatestCommand = NoggogCommand.CreateFromObject(
                objectSource: newest.WhenAnyValue(x => x.NewestSynthesisVersion),
                canExecute: v =>
            {
                return(Observable.CombineLatest(
                           this.WhenAnyValue(x => x.ManualSynthesisVersion),
                           v,
                           (manual, latest) => latest != null && latest != manual));
            },
                execute: v => ManualSynthesisVersion = v ?? string.Empty,
                extraCanExecute: this.WhenAnyValue(x => x.SynthesisVersioning)
                .Select(vers => vers == PatcherNugetVersioningEnum.Manual),
                disposable: this);

            ActiveNugetVersion = Observable.CombineLatest(
                versioning.WhenAnyValue(x => x.ActiveVersioning)
                .Switch(),
                this.WhenAnyValue(x => x.MutagenVersioning),
                this.WhenAnyValue(x => x.ManualMutagenVersion),
                newest.WhenAnyValue(x => x.NewestMutagenVersion),
                this.WhenAnyValue(x => x.SynthesisVersioning),
                this.WhenAnyValue(x => x.ManualSynthesisVersion),
                newest.WhenAnyValue(x => x.NewestSynthesisVersion),
                (profile, mutaVersioning, mutaManual, newestMuta, synthVersioning, synthManual, newestSynth) =>
            {
                var sb = new StringBuilder("Switching nuget targets");
                NugetsToUse mutagen, synthesis;
                if (mutaVersioning == PatcherNugetVersioningEnum.Profile)
                {
                    sb.Append($"  Mutagen following profile: {profile.Mutagen}");
                    mutagen = profile.Mutagen;
                }
                else
                {
                    mutagen = new NugetsToUse("Mutagen", mutaVersioning.ToNugetVersioningEnum(), mutaManual,
                                              newestMuta);
                    sb.Append($"  {mutagen}");
                }

                if (synthVersioning == PatcherNugetVersioningEnum.Profile)
                {
                    sb.Append($"  Synthesis following profile: {profile.Synthesis}");
                    synthesis = profile.Synthesis;
                }
                else
                {
                    synthesis = new NugetsToUse("Synthesis", synthVersioning.ToNugetVersioningEnum(),
                                                synthManual, newestSynth);
                    sb.Append($"  {synthesis}");
                }

                logger.Information(sb.ToString());
                return(new ActiveNugetVersioning(
                           Mutagen: mutagen,
                           Synthesis: synthesis));
            })
                                 .Select(nuget => nuget.TryGetTarget())
                                 .Replay(1)
                                 .RefCount();
        }