Moved to System.Text.Json - Removed all Library dependencies - Implemented DeleteCommand
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
@@ -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
15
Models/JsonContext.cs
Normal 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
|
||||
{
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user