replace ObservableHashSet with ObservableSortedSet
This commit is contained in:
@@ -11,8 +11,8 @@ public class SharpIdeFolder : ISharpIdeNode, IExpandableSharpIdeNode, IChildShar
|
||||
public required string Path { get; set; }
|
||||
public string ChildNodeBasePath => Path;
|
||||
public required string Name { get; set; }
|
||||
public ObservableHashSet<SharpIdeFile> Files { get; init; }
|
||||
public ObservableHashSet<SharpIdeFolder> Folders { get; init; }
|
||||
public ObservableSortedSet<SharpIdeFile> Files { get; init; }
|
||||
public ObservableSortedSet<SharpIdeFolder> Folders { get; init; }
|
||||
public bool Expanded { get; set; }
|
||||
|
||||
[SetsRequiredMembers]
|
||||
@@ -21,8 +21,8 @@ public class SharpIdeFolder : ISharpIdeNode, IExpandableSharpIdeNode, IChildShar
|
||||
Parent = parent;
|
||||
Path = folderInfo.FullName;
|
||||
Name = folderInfo.Name;
|
||||
Files = new ObservableHashSet<SharpIdeFile>(folderInfo.GetFiles(this, allFiles));
|
||||
Folders = new ObservableHashSet<SharpIdeFolder>(this.GetSubFolders(this, allFiles, allFolders));
|
||||
Files = new ObservableSortedSet<SharpIdeFile>(folderInfo.GetFiles(this, allFiles), SharpIdeFileComparer.Instance);
|
||||
Folders = new ObservableSortedSet<SharpIdeFolder>(this.GetSubFolders(this, allFiles, allFolders), SharpIdeFolderComparer.Instance);
|
||||
}
|
||||
|
||||
public SharpIdeFolder()
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace SharpIDE.Application.Features.SolutionDiscovery;
|
||||
|
||||
public class SharpIdeFileComparer : IComparer<SharpIdeFile>
|
||||
{
|
||||
public static readonly SharpIdeFileComparer Instance = new SharpIdeFileComparer();
|
||||
public int Compare(SharpIdeFile? x, SharpIdeFile? y)
|
||||
{
|
||||
if (ReferenceEquals(x, y)) return 0;
|
||||
if (x is null) return -1;
|
||||
if (y is null) return 1;
|
||||
|
||||
int result = string.Compare(x.Path, y.Path, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class SharpIdeFolderComparer : IComparer<SharpIdeFolder>
|
||||
{
|
||||
public static readonly SharpIdeFolderComparer Instance = new SharpIdeFolderComparer();
|
||||
public int Compare(SharpIdeFolder? x, SharpIdeFolder? y)
|
||||
{
|
||||
if (ReferenceEquals(x, y)) return 0;
|
||||
if (x is null) return -1;
|
||||
if (y is null) return 1;
|
||||
|
||||
int result = string.Compare(x.Path, y.Path, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,8 @@ public interface IExpandableSharpIdeNode
|
||||
|
||||
public interface IFolderOrProject : IExpandableSharpIdeNode, IChildSharpIdeNode
|
||||
{
|
||||
public ObservableHashSet<SharpIdeFolder> Folders { get; init; }
|
||||
public ObservableHashSet<SharpIdeFile> Files { get; init; }
|
||||
public ObservableSortedSet<SharpIdeFolder> Folders { get; init; }
|
||||
public ObservableSortedSet<SharpIdeFile> Files { get; init; }
|
||||
public string Name { get; set; }
|
||||
public string ChildNodeBasePath { get; }
|
||||
}
|
||||
@@ -96,8 +96,8 @@ public class SharpIdeProjectModel : ISharpIdeNode, IExpandableSharpIdeNode, IChi
|
||||
public required string Name { get; set; }
|
||||
public required string FilePath { get; set; }
|
||||
public string ChildNodeBasePath => Path.GetDirectoryName(FilePath)!;
|
||||
public required ObservableHashSet<SharpIdeFolder> Folders { get; init; }
|
||||
public required ObservableHashSet<SharpIdeFile> Files { get; init; }
|
||||
public required ObservableSortedSet<SharpIdeFolder> Folders { get; init; }
|
||||
public required ObservableSortedSet<SharpIdeFile> Files { get; init; }
|
||||
public bool Expanded { get; set; }
|
||||
public required IExpandableSharpIdeNode Parent { get; set; }
|
||||
public bool Running { get; set; }
|
||||
@@ -110,8 +110,8 @@ public class SharpIdeProjectModel : ISharpIdeNode, IExpandableSharpIdeNode, IChi
|
||||
Parent = parent;
|
||||
Name = projectModel.Model.ActualDisplayName;
|
||||
FilePath = projectModel.FullFilePath;
|
||||
Files = new ObservableHashSet<SharpIdeFile>(TreeMapperV2.GetFiles(projectModel.FullFilePath, this, allFiles));
|
||||
Folders = new ObservableHashSet<SharpIdeFolder>(TreeMapperV2.GetSubFolders(projectModel.FullFilePath, this, allFiles, allFolders));
|
||||
Files = new ObservableSortedSet<SharpIdeFile>(TreeMapperV2.GetFiles(projectModel.FullFilePath, this, allFiles), SharpIdeFileComparer.Instance);
|
||||
Folders = new ObservableSortedSet<SharpIdeFolder>(TreeMapperV2.GetSubFolders(projectModel.FullFilePath, this, allFiles, allFolders), SharpIdeFolderComparer.Instance);
|
||||
MsBuildEvaluationProjectTask = ProjectEvaluation.GetProject(projectModel.FullFilePath);
|
||||
allProjects.Add(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user