Beispiel #1
0
        private void BuildSolutionPath()
        {
            SolutionPath = currentCell.GetPath();

            TotalVisited = TotalVisited - 1;

            PathFound = true;

            PathLength = SolutionPath.Count();
        }
        public ExistingSolutionInitVm(
            IGameCategoryContext gameCategoryContext,
            IPatcherFactory patcherFactory,
            IValidateProjectPath validateProjectPath,
            ICreateProject createProject,
            IAddProjectToSolution addProjectToSolution)
        {
            SolutionPath.PathType         = PathPickerVM.PathTypeOptions.File;
            SolutionPath.ExistCheckOption = PathPickerVM.CheckOptions.On;
            SolutionPath.Filters.Add(new CommonFileDialogFilter("Solution", ".sln"));

            var validation = Observable.CombineLatest(
                SolutionPath.PathState(),
                this.WhenAnyValue(x => x.ProjectName),
                (sln, proj) => (sln, proj, validation: validateProjectPath.Validate(proj, sln)))
                             .Replay(1)
                             .RefCount();

            _projectError = validation
                            .Select(i => (ErrorResponse)i.validation)
                            .ToGuiProperty <ErrorResponse>(this, nameof(ProjectError), ErrorResponse.Success);

            InitializationCall = validation
                                 .Select((i) =>
            {
                if (!i.sln.Succeeded)
                {
                    return(i.sln.BubbleFailure <InitializerCall>());
                }
                if (!i.validation.Succeeded)
                {
                    return(i.validation.BubbleFailure <InitializerCall>());
                }
                return(GetResponse <InitializerCall> .Succeed(async() =>
                {
                    createProject.Create(gameCategoryContext.Category, i.validation.Value);
                    addProjectToSolution.Add(i.sln.Value, i.validation.Value);
                    var patcher = patcherFactory.GetSolutionPatcher(new SolutionPatcherSettings()
                    {
                        SolutionPath = i.sln.Value,
                        ProjectSubpath = Path.Combine(i.proj, $"{i.proj}.csproj"),
                    });
                    return patcher.AsEnumerable();
                }));
            });
        }
Beispiel #3
0
        public ExistingSolutionInitVM()
        {
            SolutionPath.PathType         = PathPickerVM.PathTypeOptions.File;
            SolutionPath.ExistCheckOption = PathPickerVM.CheckOptions.On;
            SolutionPath.Filters.Add(new CommonFileDialogFilter("Solution", ".sln"));

            var validation = Observable.CombineLatest(
                SolutionPath.PathState(),
                this.WhenAnyValue(x => x.ProjectName),
                (sln, proj) => (sln, proj, validation: SolutionInitialization.ValidateProjectPath(proj, sln)))
                             .Replay(1)
                             .RefCount();

            _ProjectError = validation
                            .Select(i => (ErrorResponse)i.validation)
                            .ToGuiProperty <ErrorResponse>(this, nameof(ProjectError), ErrorResponse.Success);

            InitializationCall = validation
                                 .Select((i) =>
            {
                if (!i.sln.Succeeded)
                {
                    return(i.sln.BubbleFailure <InitializerCall>());
                }
                if (!i.validation.Succeeded)
                {
                    return(i.validation.BubbleFailure <InitializerCall>());
                }
                return(GetResponse <InitializerCall> .Succeed(async(profile) =>
                {
                    var patcher = new SolutionPatcherVM(profile);
                    SolutionInitialization.CreateProject(i.validation.Value, patcher.Profile.Release.ToCategory());
                    SolutionInitialization.AddProjectToSolution(i.sln.Value, i.validation.Value);
                    patcher.SolutionPath.TargetPath = i.sln.Value;
                    patcher.ProjectSubpath = Path.Combine(i.proj, $"{i.proj}.csproj");
                    return patcher.AsEnumerable();
                }));
            });
        }