Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/AStar.Dev.File.App/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public partial class App : Application
{
private IServiceProvider? _services;

public IServiceProvider? Services => _services;

public T? GetService<T>() where T : class => _services?.GetService(typeof(T)) as T;

public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
Expand Down Expand Up @@ -56,8 +60,10 @@ private static IServiceProvider BuildServices()

services.AddSingleton<IFileTypeClassifier, FileTypeClassifier>();
services.AddSingleton<IFolderPickerService, FolderPickerService>();
services.AddSingleton<IFileDeleteService, FileDeleteService>();
services.AddTransient<IFileScannerService, FileScannerService>();
services.AddTransient<MainWindowViewModel>();
services.AddTransient<DeletePendingViewModel>();

return services.BuildServiceProvider();
}
Expand Down
7 changes: 7 additions & 0 deletions src/AStar.Dev.File.App/Data/FileAppDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace AStar.Dev.File.App.Data;
public class FileAppDbContext(DbContextOptions<FileAppDbContext> options) : DbContext(options)
{
public DbSet<ScannedFile> ScannedFiles => Set<ScannedFile>();
public DbSet<AppSetting> AppSettings => Set<AppSetting>();

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
Expand All @@ -19,5 +20,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.FileType)
.HasConversion<string>();
});

modelBuilder.Entity<AppSetting>(entity =>
{
entity.HasKey(e => e.Id);
entity.HasIndex(e => e.Key).IsUnique();
});
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions src/AStar.Dev.File.App/Migrations/20260401200334_AddAppSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace AStar.Dev.File.App.Migrations
{
/// <inheritdoc />
public partial class AddAppSettings : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AppSettings",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Key = table.Column<string>(type: "TEXT", nullable: false),
Value = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AppSettings", x => x.Id);
});

migrationBuilder.CreateIndex(
name: "IX_AppSettings_Key",
table: "AppSettings",
column: "Key",
unique: true);
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AppSettings");
}
}
}
22 changes: 22 additions & 0 deletions src/AStar.Dev.File.App/Migrations/FileAppDbContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@ protected override void BuildModel(ModelBuilder modelBuilder)
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.4");

modelBuilder.Entity("AStar.Dev.File.App.Models.AppSetting", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");

b.Property<string>("Key")
.IsRequired()
.HasColumnType("TEXT");

b.Property<string>("Value")
.IsRequired()
.HasColumnType("TEXT");

b.HasKey("Id");

b.HasIndex("Key")
.IsUnique();

b.ToTable("AppSettings");
});

modelBuilder.Entity("AStar.Dev.File.App.Models.ScannedFile", b =>
{
b.Property<int>("Id")
Expand Down
10 changes: 10 additions & 0 deletions src/AStar.Dev.File.App/Models/AppSetting.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace AStar.Dev.File.App.Models;

public class AppSetting
{
public int Id { get; set; }

public required string Key { get; set; }

public required string Value { get; set; }
}
Loading
Loading