Files
SharpIDE/src/SharpIDE.Application/Features/SolutionDiscovery/SharpIdeFile.cs
2025-10-19 11:27:06 +10:00

35 lines
1.5 KiB
C#

using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis;
using R3;
using SharpIDE.Application.Features.Events;
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
namespace SharpIDE.Application.Features.SolutionDiscovery;
public class SharpIdeFile : ISharpIdeNode, IChildSharpIdeNode
{
public required IExpandableSharpIdeNode Parent { get; set; }
public required string Path { get; set; }
public required string Name { 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);
public bool IsCsharpFile => Path.EndsWith(".cs", StringComparison.OrdinalIgnoreCase);
public bool IsRoslynWorkspaceFile => IsCsharpFile || IsRazorFile || IsCshtmlFile;
public required ReactiveProperty<bool> IsDirty { get; init; }
public required bool SuppressDiskChangeEvents { get; set; } // probably has concurrency issues
public required DateTimeOffset? LastIdeWriteTime { get; set; }
public EventWrapper<Task> FileContentsChangedExternally { get; } = new(() => Task.CompletedTask);
[SetsRequiredMembers]
internal SharpIdeFile(string fullPath, string name, IExpandableSharpIdeNode parent, ConcurrentBag<SharpIdeFile> allFiles)
{
Path = fullPath;
Name = name;
Parent = parent;
IsDirty = new ReactiveProperty<bool>(false);
SuppressDiskChangeEvents = false;
allFiles.Add(this);
}
}