Added SZ singleton and services

This commit is contained in:
2026-01-25 16:47:29 -06:00
parent 74ee8eefc3
commit 800b5d9def
8 changed files with 140 additions and 12 deletions

View File

@@ -0,0 +1,51 @@
namespace SzCore.Defaults;
public class DefaultLocalFileManager : ISzFileManager
{
public string DataPath
{
get
{
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
return path;
}
}
public string DatasetsPath => Path.Combine(DataPath, "datasets");
public bool SaveFile(string path, string fileContent)
{
try
{
var dir = Path.GetDirectoryName(path);
if (dir is null) return false;
Directory.CreateDirectory(dir);
File.WriteAllText(path, fileContent);
return true;
}
catch (Exception e)
{
Console.WriteLine($"Error saving file: {e.Message}");
return false;
}
}
public string? LoadFile(string path)
{
try
{
return File.ReadAllText(path);
}
catch (Exception e)
{
Console.WriteLine($"Error loading file: {e.Message}");
return null;
}
}
}