add new file v2
This commit is contained in:
@@ -23,6 +23,19 @@ public class IdeFileExternalChangeHandler
|
||||
if (sharpIdeFile == null)
|
||||
{
|
||||
// If sharpIdeFile is null, it means the file was created externally, and we need to create it and add it to the solution model
|
||||
var createdFileDirectory = Path.GetDirectoryName(filePath)!;
|
||||
|
||||
// TODO: Handle being contained by a project directly
|
||||
//var containingProject = SolutionModel.AllProjects.SingleOrDefault(p => createdFileDirectory == Path.GetDirectoryName(p.FilePath));
|
||||
var containingFolder = SolutionModel.AllFolders.SingleOrDefault(f => f.Path == createdFileDirectory);
|
||||
if (containingFolder is null)
|
||||
{
|
||||
// TODO: Create the folder and add it to the solution model
|
||||
}
|
||||
|
||||
sharpIdeFile = new SharpIdeFile(filePath, Path.GetFileName(filePath), containingFolder, []);
|
||||
containingFolder.Files.Add(sharpIdeFile);
|
||||
SolutionModel.AllFiles.Add(sharpIdeFile);
|
||||
// sharpIdeFile = TODO;
|
||||
}
|
||||
Guard.Against.Null(sharpIdeFile, nameof(sharpIdeFile));
|
||||
|
||||
@@ -73,7 +73,9 @@ public sealed class IdeFileWatcher : IDisposable
|
||||
|
||||
private void HandleCreated(string fullPath)
|
||||
{
|
||||
Console.WriteLine($"FileSystemWatcher: Created - {fullPath}");
|
||||
if (Path.HasExtension(fullPath) is false) return; // we don't care about directory changes
|
||||
//Console.WriteLine($"FileSystemWatcher: Created - {fullPath}");
|
||||
GlobalEvents.Instance.FileSystemWatcherInternal.FileCreated.InvokeParallelFireAndForget(fullPath);
|
||||
}
|
||||
|
||||
// The only changed event we care about is files, not directories
|
||||
|
||||
Reference in New Issue
Block a user