From 3ef7bf1784cc8cb012139ae8111a5d9627d1c443 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sun, 17 Jul 2022 12:54:37 +0200 Subject: [PATCH] Keep track of the data file's path --- I18N Commander/DataModel/Setup.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/I18N Commander/DataModel/Setup.cs b/I18N Commander/DataModel/Setup.cs index ed1388d..2b87b24 100644 --- a/I18N Commander/DataModel/Setup.cs +++ b/I18N Commander/DataModel/Setup.cs @@ -11,6 +11,10 @@ public static class Setup private const string DB_READ_WRITE_MODE = "ReadWrite"; private const string DB_READ_WRITE_CREATE_MODE = "ReadWriteCreate"; + private static string usedDataFile = string.Empty; + + public static string DataFile => Setup.usedDataFile; + /// /// Tries to migrate the data file. /// @@ -30,7 +34,8 @@ public static class Setup /// public static void AddDatabase(this IServiceCollection serviceCollection, string path2DataFile, bool createWhenNecessary = true) { - serviceCollection.AddDbContext(options => options.UseSqlite($"Filename={path2DataFile};Mode={(createWhenNecessary ? DB_READ_WRITE_CREATE_MODE : DB_READ_WRITE_MODE)}"), ServiceLifetime.Transient); + Setup.usedDataFile = path2DataFile; + serviceCollection.AddDbContext(options => options.UseSqlite($"Filename={path2DataFile};Mode={(createWhenNecessary ? DB_READ_WRITE_CREATE_MODE : DB_READ_WRITE_MODE)};"), ServiceLifetime.Transient); } ///