private DirectoryViewModel CreateDirectoryViewModel(ProjectFolder projectFolder, DirectoryViewModel parent)
 {
     var viewModel = new DirectoryViewModel(parent, projectFolder);
     if (_settings.IsFlatMode) {
         foreach (var project in new[]{projectFolder}.Flatten(f => f.Projects, f => f.Folders)) {
             viewModel.Projects.Add(CreateProjectViewModel(project, viewModel));
         }
     } else {
         foreach (var folder in projectFolder.Folders) {
             viewModel.Directories.Add(CreateDirectoryViewModel(folder, viewModel));
         }
         foreach (var project in projectFolder.Projects) {
             viewModel.Projects.Add(CreateProjectViewModel(project, viewModel));
         }
     }
     return viewModel;
 }
Example #2
0
 public ProjectFolder(string fullPath, ProjectFolder parent)
 {
     _fullPath = fullPath;
     _parent = parent;
     _name = Path.GetFileName(fullPath);
 }
 public DirectoryViewModel(DirectoryViewModel parent, ProjectFolder projectFolder)
     : base(parent)
 {
     _projectFolder = projectFolder;
 }
 public ScanResult(ProjectFolder projectFolder, IDictionary<string, Project> projects)
 {
     Projects = projects;
     ProjectFolder = projectFolder;
 }
        private ProjectFolder CreateProjectFolder(string path, ProjectFolder parent)
        {
            if (_cancellationToken.IsCancellationRequested) {
                return null;
            }

            var projectFolder = new ProjectFolder(path, parent);
            foreach (var subdirectory in Directory.EnumerateDirectories(path)) {
                var folder = CreateProjectFolder(subdirectory, projectFolder);
                if (folder != null && !folder.IsEmpty) {
                    if (_simplifyProjectTree && folder.Folders.Count == 0 && folder.Projects.Count == 1) {
                        // if a subfolder contains a project only and no other folders, just add that project instead of the subfolder
                        var project = folder.Projects[0];
                        project.Parent = projectFolder;
                        projectFolder.Projects.Add(project);
                    } else {
                        projectFolder.Folders.Add(folder);
                    }
                }
            }
            foreach (var projectPath in Directory.EnumerateFiles(path, "*.csproj", SearchOption.TopDirectoryOnly)) {
                projectFolder.Projects.Add(CreateProject(projectPath, projectFolder));
            }

            // if the folder contains no project but one subfolder, skip the subfolder and add its content instead
            if (_simplifyProjectTree && projectFolder.Projects.Count == 0 && projectFolder.Folders.Count == 1) {
                var subfolder = projectFolder.Folders[0];
                projectFolder.Folders.Clear();
                foreach (var folder in subfolder.Folders) {
                    folder.Parent = projectFolder;
                    projectFolder.Folders.Add(folder);
                }
                foreach (var project in subfolder.Projects) {
                    project.Parent = projectFolder;
                    projectFolder.Projects.Add(project);
                }
            }

            return projectFolder;
        }
 private Project CreateProject(string projectPath, ProjectFolder projectFolder)
 {
     return _projects.GetOrAdd(projectPath, path => {
         ProgressText = _projects.Count + " projects loaded";
         return new Project(path, projectFolder);
     });
 }
Example #7
0
 public Project(string filepath, ProjectFolder parent)
 {
     _filepath = filepath;
     _parent = parent;
     _name = Path.GetFileNameWithoutExtension(_filepath);
 }
Example #8
0
 public Project(string filepath, ProjectFolder parent)
 {
     _filepath = filepath;
     _parent   = parent;
     _name     = Path.GetFileNameWithoutExtension(_filepath);
 }