dcb3637cca
LayoutStore.cs 1402 -> 47-line shell + 5 partials, grouped by functionality (line count is a consequence, not the goal): - LayoutStore.Migrations.cs: all DB schema migration (EnsureSchema, GetUserVersion, MigrateSourceTable/WebcamConfigTable/ToV3/SceneTable/SceneSocialBarColumn/ SocialsTable/SocialEntryTable) - LayoutStore.Load.cs: Load() scene/source read-back - LayoutStore.Save.cs: Save() full scene tree write - LayoutStore.Settings.cs: key/value settings + mic/record-folder/reusable-stream + license/transition/broadcast/hotkey/window-state GetSetting/UpsertSetting - LayoutStore.Assets.cs: GetAssetBytes/UpsertAsset blob IO - LayoutStore.cs: shell — Instance, fields, ctor, Dispose Converted to public partial class LayoutStore : IDisposable. Pruned per-file dead usings. Phase 3 DOWN: no production .cs exceeds 500 lines. Zero behavior change; build 0 warnings; 246 pass, only the 2 known failures. Docs: ViewModels/index.md Phase 3 tracker updated in same commit.
48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using System.IO;
|
|
using Microsoft.Data.Sqlite;
|
|
using ytLive.Models;
|
|
|
|
namespace ytLive.Services;
|
|
|
|
public partial class LayoutStore : IDisposable
|
|
{
|
|
public static LayoutStore? Instance { get; private set; }
|
|
|
|
private readonly SqliteConnection _connection;
|
|
public string ActivePath { get; }
|
|
|
|
/// <summary>The app-wide webcam identity loaded with the last Load() (null = never picked).</summary>
|
|
public Webcam? Webcam { get; private set; }
|
|
|
|
/// <summary>The app-wide social bar config loaded with the last Load() (null = never defined).</summary>
|
|
public SocialsConfig? Socials { get; private set; }
|
|
|
|
/// <summary>The app-wide background music (TASK 9 TRAX) loaded with the last
|
|
/// Load() (null = no track chosen).</summary>
|
|
public Music? Music { get; private set; }
|
|
public LayoutStore(string path)
|
|
{
|
|
ActivePath = path;
|
|
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
|
|
_connection = new SqliteConnection($"Data Source={path}");
|
|
_connection.Open();
|
|
using (var pragma = _connection.CreateCommand())
|
|
{
|
|
pragma.CommandText = "PRAGMA foreign_keys = ON;";
|
|
pragma.ExecuteNonQuery();
|
|
}
|
|
EnsureSchema();
|
|
Instance = this;
|
|
}
|
|
private int GetUserVersion()
|
|
{
|
|
using var cmd = _connection.CreateCommand();
|
|
cmd.CommandText = "PRAGMA user_version;";
|
|
return Convert.ToInt32(cmd.ExecuteScalar());
|
|
}
|
|
public void Dispose()
|
|
{
|
|
_connection.Dispose();
|
|
}
|
|
}
|