/// <exception cref="IOException" /> /// <exception cref="UnauthorizedAccessException" /> IEnumerable <AbsoluteFilePath> GetProjectsContaining(AbsoluteFilePath fileInProject) { if (fileInProject.IsProjectFile()) { return new[] { fileInProject } } ; return(GetProjectsInOrContaining(fileInProject.ContainingDirectory)); // TODO: maybe actually open the project to see if it contains the file } /// <exception cref="IOException" /> /// <exception cref="UnauthorizedAccessException" /> IEnumerable <AbsoluteFilePath> GetProjectsInOrContaining(AbsoluteDirectoryPath projectDirectory) { var currentDirectory = projectDirectory; do { foreach (var file in GetProjectsIn(currentDirectory)) { yield return(file); } } while ((currentDirectory = currentDirectory.ContainingDirectory) != null); } /// <exception cref="IOException" /> /// <exception cref="UnauthorizedAccessException" /> IEnumerable <AbsoluteFilePath> GetProjectsIn(AbsoluteDirectoryPath dir) { return(_fileSystem.GetFiles(dir).Where(file => file.IsProjectFile())); } }