private SolutionFileProjectReference AcquireAndAddSolutionFolderProject(SolutionFile solutionFile, string solutionFolderPath) { var solutionFolderPathParts = this.SolutionFolderPathOperator.GetSolutionFolderPathParts(solutionFolderPath); VisualStudioSolutionFileOperator.VerifyNonEmptySolutionFolderPath(solutionFolderPathParts); var rootSolutionFolderName = solutionFolderPathParts.First(); var rootSolutionFolderProject = this.AcquireAndAddRootSolutionFolderProject(solutionFile, rootSolutionFolderName); var solutionFolderPathPartCount = solutionFolderPathParts.Count(); if (solutionFolderPathPartCount < 2) { // There is only a root. return(rootSolutionFolderProject); } // Recurse down the solution folders. var currentSolutionFolderProject = rootSolutionFolderProject; foreach (var solutionFolderName in solutionFolderPathParts.Skip(1)) // Skip the root. { currentSolutionFolderProject = this.AcquireAndAddChildSolutionFolderProject(solutionFile, solutionFolderName, currentSolutionFolderProject); } return(currentSolutionFolderProject); }
public bool HasSolutionFolder(SolutionFile solutionFile, string solutionFolderPath, out SolutionFileProjectReference solutionFolder) { var solutionFolderPathParts = this.SolutionFolderPathOperator.GetSolutionFolderPathParts(solutionFolderPath); VisualStudioSolutionFileOperator.VerifyNonEmptySolutionFolderPath(solutionFolderPathParts); var rootSolutionFolderName = solutionFolderPathParts.First(); var hasRootSolutionFolder = this.HasRootSolutionFolderProject(solutionFile, rootSolutionFolderName, out var rootSolutionFolder); if (!hasRootSolutionFolder) { solutionFolder = default; return(false); } var solutionFolderPathPartCount = solutionFolderPathParts.Count(); if (solutionFolderPathPartCount < 2) { // There is only a root. solutionFolder = rootSolutionFolder; return(hasRootSolutionFolder); } // Recurse down the solution folders. var currentSolutionFolderProject = rootSolutionFolder; foreach (var solutionFolderName in solutionFolderPathParts.Skip(1)) // Skip the root. { var hasChildSolutionFolder = this.HasChildSolutionFolderProject(solutionFile, solutionFolderName, currentSolutionFolderProject, out currentSolutionFolderProject); if (!hasChildSolutionFolder) { solutionFolder = default; return(false); } } solutionFolder = currentSolutionFolderProject; return(true); }