public async Task EnumerateSolutionsInRepository(RepositoryInfo repository) { Dictionary <string, Stream?> SolutionStreamTable = await GitHubApi.GitHub.EnumerateFiles(repository.Source, "/", ".sln"); NotifyStatusUpdated(); bool IsMainProjectExe = false; foreach (KeyValuePair <string, Stream?> Entry in SolutionStreamTable) { if (Entry.Value != null) { string SolutionName = Path.GetFileNameWithoutExtension(Entry.Key); Stream SolutionStream = Entry.Value; using StreamReader Reader = new(SolutionStream, Encoding.UTF8); SlnExplorer.Solution Solution = new(SolutionName, Reader); List <ProjectInfo> LoadedProjectList = new(); foreach (SlnExplorer.Project ProjectItem in Solution.ProjectList) { bool IsIgnored = ProjectItem.ProjectType > SlnExplorer.ProjectType.KnownToBeMSBuildFormat; if (!IsIgnored) { byte[]? Content = await GitHubApi.GitHub.DownloadFile(repository.Source, ProjectItem.RelativePath); NotifyStatusUpdated(); if (Content != null) { using MemoryStream Stream = new MemoryStream(Content); ProjectItem.LoadDetails(Stream); } ProjectInfo NewProject = new(ProjectList, ProjectItem); ProjectList.Add(NewProject); LoadedProjectList.Add(NewProject); } } if (LoadedProjectList.Count > 0) { SolutionInfo NewSolution = new(SolutionList, repository, Solution, LoadedProjectList); SolutionList.Add(NewSolution); foreach (ProjectInfo Item in NewSolution.ProjectList) { Item.ParentSolution = NewSolution; } repository.SolutionList.Add(NewSolution); IsMainProjectExe |= CheckMainProjectExe(NewSolution); } } } repository.IsMainProjectExe = IsMainProjectExe; }
/// <summary> /// Create a puzzle solution out of the Dlx result. /// </summary> /// <param name="rows">The remaining Dlx nodes containing the solution values.</param> private void SolutionFound(IEnumerable <DlxNode> rows) { var size = _puzzleSize.ToInt32(); var newSolution = new Dictionary <PuzzleCoordinate, int>(); foreach (var rowNode in rows) { if (rowNode != null) { var value = rowNode.Coordinate.Row - 1; var digit = value % size + 1; value /= size; var col = value % size; value /= size; var row = value % size; var coord = new PuzzleCoordinate(row, col); newSolution[coord] = digit; } } var solvedPuzzle = new Puzzle(_puzzleSize); foreach (var coord in newSolution.Keys.OrderBy(k => k)) { solvedPuzzle[coord] = Convert.ToByte(newSolution[coord]); } SolutionList.Add(solvedPuzzle); }
private void ExecuteSolve(object p) { string word = Model.Solve(); if (word != null) { char[] conundrum = new char[Model.cLetterCount]; for (int index = 0; index < Model.cLetterCount; ++index) { conundrum[index] = Model.Conundrum[index][0]; } Solution = word; SolutionList.Add(new ConundrumItem(new string(conundrum), word)); } }