public static bool TryParse(ICodebaseService codebaseService, CsProjectFileInfo projFileInfo, out CsProjectFile csProject) { try { csProject = CsProjectFile.Parse(codebaseService, projFileInfo); return(true); } catch { csProject = null; return(false); } }
/// <summary> /// Получает последовательность всех солюшенов из репозитория (на указанной ветке) /// </summary> public static IEnumerable <Result <CsSolution> > GetAllSolutions( ICodebaseService codebaseService , BranchInfo branch , ProgressObserver progressObserver = null) { if (codebaseService == null) { throw new ArgumentNullException(nameof(codebaseService)); } bool isSolutionFileInfo(SourceItemInfo item) => item.Type == SourceItemTypes.File && item.Extension?.ToLower() == "sln"; return(codebaseService.FindAllItems( branch , null , isSolutionFileInfo , items => items.Any(isSolutionFileInfo) , true , progressObserver) .Select(solutionFileInfo => { try { var solutionFileContent = codebaseService.GetSourceFileContent(solutionFileInfo); var solutionFile = CsSolutionFile.Parse(solutionFileContent, solutionFileInfo); var projectFiles = solutionFile.CsProjectFileInfos .Select(projectFileInfo => CsProjectFile.Parse(codebaseService, projectFileInfo)); return new Result <CsSolution> { IsSuccessful = true, Data = new CsSolution(solutionFile, projectFiles) }; } catch (Exception e) { return new Result <CsSolution> { IsSuccessful = false, Tag = solutionFileInfo, ErrorMessage = e.Message }; } })); }