public async Task <bool> ConfirmNameUnique(PatcherVm patcher)
        {
            var existingNames = _groupsList.Groups.Items
                                .SelectMany(g => g.Patchers.Items)
                                .Select(x => x.NameVm.Name)
                                .ToHashSet(StringComparer.OrdinalIgnoreCase);

            if (!existingNames.Contains(patcher.NameVm.Name))
            {
                return(true);
            }
            var rename = new PatcherInitRenameActionVm(
                patcher.NameVm.Name,
                existingNames);

            _confirmation.TargetConfirmation = rename;
            var signal = rename.ConfirmActionCommand.EndingExecution().Select(_ => true);

            if (rename.DiscardActionCommand != null)
            {
                signal = signal.Merge(rename.DiscardActionCommand.EndingExecution().Select(_ => false));
            }

            var result = await signal.Take(1);

            if (!result)
            {
                return(false);
            }

            patcher.NameVm.Nickname = rename.Name;
            return(true);
        }
Exemplo n.º 2
0
        public PatcherRunVm ToRunner(PatcherVm patcherVm)
        {
            switch (patcherVm)
            {
            case GitPatcherVm:
            case SolutionPatcherVm:
                return(ToRunner <SolutionPatcherRun>(patcherVm));

            case CliPatcherVm:
                return(ToRunner <CliPatcherRun>(patcherVm));

            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 3
0
        private PatcherRunVm ToRunner <T>(PatcherVm patcherVm)
            where T :  IPatcherRun
        {
            var scope = patcherVm.Scope.BeginLifetimeScope(LifetimeScopes.RunNickname, c =>
            {
                c.RegisterType <T>().As <IPatcherRun>();
                c.RegisterType <ReporterLoggerWrapper>()
                .AsImplementedInterfaces()
                .SingleInstance();
            });
            var runnerFactory = scope.Resolve <PatcherRunVm.Factory>();

            patcherVm.PrepForRun();
            var ret = runnerFactory(patcherVm);

            scope.DisposeWith(ret);
            return(ret);
        }