public static bool TryParse(string slnFileContent, SourceItemInfo slnFileInfo, out CsSolutionFile csSolutionFileInfo)
 {
     try
     {
         csSolutionFileInfo = CsSolutionFile.Parse(slnFileContent, slnFileInfo);
         return(true);
     }
     catch
     {
         csSolutionFileInfo = 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
                    };
                }
            }));
        }
示例#3
0
        public CsSolution(CsSolutionFile solutionFileData, IEnumerable <CsProjectFile> projectsData)
        {
            if (solutionFileData == null)
            {
                throw new ArgumentNullException(nameof(solutionFileData));
            }
            if (!solutionFileData.IsValid())
            {
                throw new ArgumentException(nameof(solutionFileData));
            }

            if (projectsData == null)
            {
                throw new ArgumentNullException(nameof(projectsData));
            }
            if (projectsData.Any(p => !p.IsValid()))
            {
                throw new ArgumentException(nameof(projectsData));
            }

            Data         = solutionFileData;
            ProjectsData = projectsData;
        }