Adding creation of data into data handler, marking the way for szdb handling

This commit is contained in:
2026-01-28 21:46:28 -06:00
parent 507e6348f6
commit 97c8128176
9 changed files with 436 additions and 25 deletions

View File

@@ -6,6 +6,7 @@ public static class SZ
{
private static ISzFileManager? _fileManager;
private static ISzLogger? _logger;
private static ISzDatabaseHandler? _dbHandler;
public static bool IsInitalized { get; private set; } = false;
@@ -33,6 +34,16 @@ public static class SZ
}
}
public static ISzDatabaseHandler DatabaseHandler
{
get
{
CheckInitialization();
if (_dbHandler is null) throw new Exception("SZ._dbHandler is null");
return _dbHandler;
}
}
private static readonly Dictionary<Type, object> _services = [];
private static readonly List<Type> _protectedServices = [];
@@ -42,12 +53,13 @@ public static class SZ
/// <param name="fileManager">An ISzFileManager instance.</param>
/// <param name="logger">An ISzLogger instance.</param>
/// /// <exception cref="Exception">Throws if SZ has already been initalized</exception>
public static void Init(ISzFileManager fileManager, ISzLogger logger)
public static void Init(ISzFileManager fileManager, ISzLogger logger, ISzDatabaseHandler databaseHandler)
{
if (IsInitalized) throw new Exception("Cannot initalize SZ more than once.");
_logger = logger;
_fileManager = fileManager;
_dbHandler = databaseHandler;
if (_logger is null)
{
@@ -59,10 +71,16 @@ public static class SZ
throw new Exception("SZ.Init failed: LocalFileManager was null");
}
if (_dbHandler is null)
{
throw new Exception("SZ.Init failed: DatabaseHandler was null");
}
IsInitalized = true;
AddService(fileManager, true);
AddService(logger, true);
AddService(databaseHandler, true);
logger.Log(" -- SZ CORE INITALIZED -- ");
}