v1.0 release

This commit is contained in:
Cameron
2024-08-27 03:29:38 -05:00
parent a4403ce17b
commit ef7c3f9dbd
38 changed files with 1172 additions and 73 deletions

View File

@@ -0,0 +1,31 @@
using System.Text.Json;
namespace ComiServ.Services
{
public class Configuration
{
public string LibraryRoot { get; set; }
public string DatabaseFile { get; set; }
public double AutoScanPeriodHours { get; set; }
public Configuration Copy()
=> MemberwiseClone() as Configuration
//this really shouldn't be possible
?? throw new Exception("Failed to clone configuration");
}
public interface IConfigService
{
public Configuration Config { get; }
}
public class JsonConfigService : IConfigService
{
public Configuration _Config;
//protect original
public Configuration Config => _Config.Copy();
public JsonConfigService(string filepath)
{
using var fileStream = File.OpenRead(filepath);
_Config = JsonSerializer.Deserialize<Configuration>(fileStream)
?? throw new ArgumentException("Failed to parse config file");
}
}
}