add delete directory

This commit is contained in:
Matt Parker
2025-10-20 00:39:08 +10:00
parent e379d064f3
commit 4278b729dc
6 changed files with 51 additions and 3 deletions

View File

@@ -12,4 +12,10 @@ public class IdeFileOperationsService(SharpIdeSolutionModificationService sharpI
Directory.CreateDirectory(newDirectoryPath);
var newFolder = await _sharpIdeSolutionModificationService.AddDirectory(parentFolder, newDirectoryName);
}
public async Task DeleteDirectory(SharpIdeFolder folder)
{
Directory.Delete(folder.Path, true);
await _sharpIdeSolutionModificationService.RemoveDirectory(folder);
}
}

View File

@@ -17,4 +17,11 @@ public class SharpIdeSolutionModificationService
SolutionModel.AllFolders.Add(sharpIdeFolder);
return sharpIdeFolder;
}
public async Task RemoveDirectory(SharpIdeFolder folder)
{
var parentFolderOrProject = (IFolderOrProject)folder.Parent;
parentFolderOrProject.Folders.Remove(folder);
SolutionModel.AllFolders.Remove(folder);
}
}

View File

@@ -5,7 +5,7 @@ using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
namespace SharpIDE.Application.Features.SolutionDiscovery;
public class SharpIdeFolder : ISharpIdeNode, IExpandableSharpIdeNode, IChildSharpIdeNode
public class SharpIdeFolder : ISharpIdeNode, IExpandableSharpIdeNode, IChildSharpIdeNode, IFolderOrProject
{
public required IExpandableSharpIdeNode Parent { get; set; }
public required string Path { get; set; }

View File

@@ -14,6 +14,12 @@ public interface IExpandableSharpIdeNode
{
public bool Expanded { get; set; }
}
public interface IFolderOrProject
{
public ObservableHashSet<SharpIdeFolder> Folders { get; init; }
public ObservableHashSet<SharpIdeFile> Files { get; init; }
}
public interface IChildSharpIdeNode
{
public IExpandableSharpIdeNode Parent { get; set; }