Add .razor icon
This commit is contained in:
@@ -143,7 +143,7 @@ public class SharpIdeSolutionModificationService(FileChangedService fileChangedS
|
||||
|
||||
public async Task<SharpIdeFile> CreateFile(IFolderOrProject parentNode, string newFilePath, string fileName, string contents)
|
||||
{
|
||||
var sharpIdeFile = new SharpIdeFile(newFilePath, fileName, parentNode, []);
|
||||
var sharpIdeFile = new SharpIdeFile(newFilePath, fileName, Path.GetExtension(newFilePath), parentNode, []);
|
||||
|
||||
var correctInsertionPosition = GetInsertionPosition(parentNode, sharpIdeFile);
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ public class SharpIdeFile : ISharpIdeNode, IChildSharpIdeNode, IFileOrFolder
|
||||
public required IExpandableSharpIdeNode Parent { get; set; }
|
||||
public required string Path { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public required string Extension { get; set; }
|
||||
public bool IsRazorFile => Path.EndsWith(".razor", StringComparison.OrdinalIgnoreCase);
|
||||
public bool IsCsprojFile => Path.EndsWith(".csproj", StringComparison.OrdinalIgnoreCase);
|
||||
public bool IsCshtmlFile => Path.EndsWith(".cshtml", StringComparison.OrdinalIgnoreCase);
|
||||
@@ -25,10 +26,11 @@ public class SharpIdeFile : ISharpIdeNode, IChildSharpIdeNode, IFileOrFolder
|
||||
public EventWrapper<Task> FileDeleted { get; } = new(() => Task.CompletedTask);
|
||||
|
||||
[SetsRequiredMembers]
|
||||
internal SharpIdeFile(string fullPath, string name, IExpandableSharpIdeNode parent, ConcurrentBag<SharpIdeFile> allFiles)
|
||||
internal SharpIdeFile(string fullPath, string name, string extension, IExpandableSharpIdeNode parent, ConcurrentBag<SharpIdeFile> allFiles)
|
||||
{
|
||||
Path = fullPath;
|
||||
Name = name;
|
||||
Extension = extension;
|
||||
Parent = parent;
|
||||
IsDirty = new ReactiveProperty<bool>(false);
|
||||
SuppressDiskChangeEvents = false;
|
||||
|
||||
@@ -75,7 +75,7 @@ public static class TreeMapperV2
|
||||
return [];
|
||||
}
|
||||
|
||||
var sharpIdeFiles = fileInfos.Select(f => new SharpIdeFile(f.FullName, f.Name, parent, allFiles)
|
||||
var sharpIdeFiles = fileInfos.Select(f => new SharpIdeFile(f.FullName, f.Name, f.Extension, parent, allFiles)
|
||||
{
|
||||
Path = f.FullName,
|
||||
Name = f.Name,
|
||||
|
||||
@@ -14,7 +14,7 @@ public static class IntermediateMapper
|
||||
var serializer = SolutionSerializers.GetSerializerByMoniker(solutionFilePath);
|
||||
Guard.Against.Null(serializer, nameof(serializer));
|
||||
var vsSolution = await serializer.OpenAsync(solutionFilePath, cancellationToken);
|
||||
|
||||
|
||||
// Remove any projects that aren't csproj, TODO: Instead of removing, display in the solution explorer that the project type isn't supported
|
||||
foreach (var vsSolutionSolutionProject in vsSolution.SolutionProjects.Where(s => s.Extension is not ".csproj").ToList())
|
||||
{
|
||||
@@ -59,10 +59,15 @@ public static class IntermediateMapper
|
||||
.ToList();
|
||||
|
||||
var filesInFolder = folder.Files?
|
||||
.Select(f => new IntermediateSlnFolderFileModel
|
||||
.Select(f =>
|
||||
{
|
||||
Name = Path.GetFileName(f),
|
||||
FullPath = new FileInfo(Path.Join(Path.GetDirectoryName(solutionFilePath), f)).FullName
|
||||
var fileInfo = new FileInfo(Path.Join(Path.GetDirectoryName(solutionFilePath), f));
|
||||
return new IntermediateSlnFolderFileModel
|
||||
{
|
||||
Name = Path.GetFileName(f),
|
||||
FullPath = fileInfo.FullName,
|
||||
Extension = fileInfo.Extension
|
||||
};
|
||||
})
|
||||
.ToList() ?? [];
|
||||
|
||||
|
||||
@@ -29,4 +29,5 @@ internal class IntermediateSlnFolderFileModel
|
||||
{
|
||||
public required string Name { get; set; }
|
||||
public required string FullPath { get; set; }
|
||||
public required string Extension { get; set; }
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class SharpIdeSolutionFolder : ISharpIdeNode, IExpandableSharpIdeNode, IC
|
||||
{
|
||||
Name = intermediateModel.Model.Name;
|
||||
Parent = parent;
|
||||
Files = new ObservableHashSet<SharpIdeFile>(intermediateModel.Files.Select(s => new SharpIdeFile(s.FullPath, s.Name, this, allFiles)));
|
||||
Files = new ObservableHashSet<SharpIdeFile>(intermediateModel.Files.Select(s => new SharpIdeFile(s.FullPath, s.Name, s.Extension, 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)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user