Moved to System.Text.Json - Removed all Library dependencies - Implemented DeleteCommand

This commit is contained in:
2025-02-04 13:28:06 +03:30
parent d716133230
commit 83347587e4
10 changed files with 171 additions and 121 deletions

View File

@@ -1,11 +1,26 @@
using System.Text.Json.Serialization;
namespace TBDel.Models;
public class FileEntry
{
// Unique 5 digit number for each entry
uint Id { get; set; }
public uint Id { get; set; }
// Absolute path
public string Path { get; set; } = string.Empty;
// Date added
public DateTime DateAdded { get; set; }
public FileEntry()
{
}
// To support trimmed binary
[JsonConstructor]
public FileEntry(uint id, string path, DateTime dateAdded)
{
Id = id;
Path = path;
DateAdded = dateAdded;
}
}

View File

@@ -1,6 +1,16 @@
using System.Text.Json.Serialization;
namespace TBDel.Models;
// The same as FileEntry
public class FolderEntry : FileEntry
{
public FolderEntry() : base()
{
}
[JsonConstructor]
public FolderEntry(uint id, string path, DateTime dateAdded) : base(id, path, dateAdded)
{
}
}

15
Models/JsonContext.cs Normal file
View File

@@ -0,0 +1,15 @@
using System.Text.Json.Serialization;
using TBDel.Models;
// All this just because the binary size was 40MB for this little CLI tool
namespace TBDel.Services
{
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(DatabaseContent))]
[JsonSerializable(typeof(FileEntry))]
[JsonSerializable(typeof(FolderEntry))]
internal partial class JsonContext : JsonSerializerContext
{
}
}