Use observable collections for solution model
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ObservableCollections;
|
||||
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||
|
||||
namespace SharpIDE.Application.Features.SolutionDiscovery;
|
||||
@@ -9,8 +10,8 @@ public class SharpIdeFolder : ISharpIdeNode, IExpandableSharpIdeNode, IChildShar
|
||||
public required IExpandableSharpIdeNode Parent { get; set; }
|
||||
public required string Path { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public required List<SharpIdeFile> Files { get; set; }
|
||||
public required List<SharpIdeFolder> Folders { get; set; }
|
||||
public ObservableHashSet<SharpIdeFile> Files { get; init; }
|
||||
public ObservableHashSet<SharpIdeFolder> Folders { get; init; }
|
||||
public bool Expanded { get; set; }
|
||||
|
||||
[SetsRequiredMembers]
|
||||
@@ -19,8 +20,8 @@ public class SharpIdeFolder : ISharpIdeNode, IExpandableSharpIdeNode, IChildShar
|
||||
Parent = parent;
|
||||
Path = folderInfo.FullName;
|
||||
Name = folderInfo.Name;
|
||||
Files = folderInfo.GetFiles(this, allFiles);
|
||||
Folders = this.GetSubFolders(this, allFiles, allFolders);
|
||||
Files = new ObservableHashSet<SharpIdeFile>(folderInfo.GetFiles(this, allFiles));
|
||||
Folders = new ObservableHashSet<SharpIdeFolder>(this.GetSubFolders(this, allFiles, allFolders));
|
||||
}
|
||||
|
||||
public SharpIdeFolder()
|
||||
|
||||
@@ -35,8 +35,8 @@ public class SharpIdeSolutionModel : ISharpIdeNode, IExpandableSharpIdeNode
|
||||
public required string Name { get; set; }
|
||||
public required string FilePath { get; set; }
|
||||
public required string DirectoryPath { get; set; }
|
||||
public required List<SharpIdeProjectModel> Projects { get; set; }
|
||||
public required List<SharpIdeSolutionFolder> SlnFolders { get; set; }
|
||||
public required ObservableHashSet<SharpIdeProjectModel> Projects { get; set; }
|
||||
public required ObservableHashSet<SharpIdeSolutionFolder> SlnFolders { get; set; }
|
||||
public required HashSet<SharpIdeProjectModel> AllProjects { get; set; }
|
||||
public required HashSet<SharpIdeFile> AllFiles { get; set; }
|
||||
public required HashSet<SharpIdeFolder> AllFolders { get; set; }
|
||||
@@ -52,8 +52,8 @@ public class SharpIdeSolutionModel : ISharpIdeNode, IExpandableSharpIdeNode
|
||||
Name = solutionName;
|
||||
FilePath = solutionFilePath;
|
||||
DirectoryPath = Path.GetDirectoryName(solutionFilePath)!;
|
||||
Projects = intermediateModel.Projects.Select(s => new SharpIdeProjectModel(s, allProjects, allFiles, allFolders, this)).ToList();
|
||||
SlnFolders = intermediateModel.SolutionFolders.Select(s => new SharpIdeSolutionFolder(s, allProjects, allFiles, allFolders, this)).ToList();
|
||||
Projects = new ObservableHashSet<SharpIdeProjectModel>(intermediateModel.Projects.Select(s => new SharpIdeProjectModel(s, allProjects, allFiles, allFolders, this)));
|
||||
SlnFolders = new ObservableHashSet<SharpIdeSolutionFolder>(intermediateModel.SolutionFolders.Select(s => new SharpIdeSolutionFolder(s, allProjects, allFiles, allFolders, this)));
|
||||
AllProjects = allProjects.ToHashSet();
|
||||
AllFiles = allFiles.ToHashSet();
|
||||
AllFolders = allFolders.ToHashSet();
|
||||
@@ -62,9 +62,9 @@ public class SharpIdeSolutionModel : ISharpIdeNode, IExpandableSharpIdeNode
|
||||
public class SharpIdeSolutionFolder : ISharpIdeNode, IExpandableSharpIdeNode, IChildSharpIdeNode
|
||||
{
|
||||
public required string Name { get; set; }
|
||||
public required List<SharpIdeSolutionFolder> Folders { get; set; }
|
||||
public required List<SharpIdeProjectModel> Projects { get; set; }
|
||||
public required List<SharpIdeFile> Files { get; set; }
|
||||
public required ObservableHashSet<SharpIdeSolutionFolder> Folders { get; set; }
|
||||
public required ObservableHashSet<SharpIdeProjectModel> Projects { get; set; }
|
||||
public required ObservableHashSet<SharpIdeFile> Files { get; set; }
|
||||
public bool Expanded { get; set; }
|
||||
public required IExpandableSharpIdeNode Parent { get; set; }
|
||||
|
||||
@@ -73,17 +73,17 @@ public class SharpIdeSolutionFolder : ISharpIdeNode, IExpandableSharpIdeNode, IC
|
||||
{
|
||||
Name = intermediateModel.Model.Name;
|
||||
Parent = parent;
|
||||
Files = intermediateModel.Files.Select(s => new SharpIdeFile(s.FullPath, s.Name, this, allFiles)).ToList();
|
||||
Folders = intermediateModel.Folders.Select(x => new SharpIdeSolutionFolder(x, allProjects, allFiles, allFolders, this)).ToList();
|
||||
Projects = intermediateModel.Projects.Select(x => new SharpIdeProjectModel(x, allProjects, allFiles, allFolders, this)).ToList();
|
||||
Files = new ObservableHashSet<SharpIdeFile>(intermediateModel.Files.Select(s => new SharpIdeFile(s.FullPath, s.Name, this, allFiles)));
|
||||
Folders = new ObservableHashSet<SharpIdeSolutionFolder>(intermediateModel.Folders.Select(x => new SharpIdeSolutionFolder(x, allProjects, allFiles, allFolders, this)));
|
||||
Projects = new ObservableHashSet<SharpIdeProjectModel>(intermediateModel.Projects.Select(x => new SharpIdeProjectModel(x, allProjects, allFiles, allFolders, this)));
|
||||
}
|
||||
}
|
||||
public class SharpIdeProjectModel : ISharpIdeNode, IExpandableSharpIdeNode, IChildSharpIdeNode
|
||||
{
|
||||
public required string Name { get; set; }
|
||||
public required string FilePath { get; set; }
|
||||
public required List<SharpIdeFolder> Folders { get; set; }
|
||||
public required List<SharpIdeFile> Files { get; set; }
|
||||
public required ObservableHashSet<SharpIdeFolder> Folders { get; set; }
|
||||
public required ObservableHashSet<SharpIdeFile> Files { get; set; }
|
||||
public bool Expanded { get; set; }
|
||||
public required IExpandableSharpIdeNode Parent { get; set; }
|
||||
public bool Running { get; set; }
|
||||
@@ -96,8 +96,8 @@ public class SharpIdeProjectModel : ISharpIdeNode, IExpandableSharpIdeNode, IChi
|
||||
Parent = parent;
|
||||
Name = projectModel.Model.ActualDisplayName;
|
||||
FilePath = projectModel.FullFilePath;
|
||||
Files = TreeMapperV2.GetFiles(projectModel.FullFilePath, this, allFiles);
|
||||
Folders = TreeMapperV2.GetSubFolders(projectModel.FullFilePath, this, allFiles, allFolders);
|
||||
Files = new ObservableHashSet<SharpIdeFile>(TreeMapperV2.GetFiles(projectModel.FullFilePath, this, allFiles));
|
||||
Folders = new ObservableHashSet<SharpIdeFolder>(TreeMapperV2.GetSubFolders(projectModel.FullFilePath, this, allFiles, allFolders));
|
||||
MsBuildEvaluationProjectTask = ProjectEvaluation.GetProject(projectModel.FullFilePath);
|
||||
allProjects.Add(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user