Initial commit
This commit is contained in:
+102
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace TvSyncApp
|
||||
{
|
||||
public class Settings
|
||||
{
|
||||
public GlobalSettings? Global { get; set; }
|
||||
public DbSettings? DbSettings { get; set; }
|
||||
public ApiSettings? Api { get; set; }
|
||||
public JsonSettings? Json { get; set; }
|
||||
public DatabaseSettings? Database { get; set; }
|
||||
public UpdateTypeSettings? UpdateType { get; set; }
|
||||
|
||||
public static Settings Load(string filePath)
|
||||
{
|
||||
if (!File.Exists(filePath))
|
||||
throw new FileNotFoundException($"Settings file not found: {filePath}");
|
||||
|
||||
var json = File.ReadAllText(filePath);
|
||||
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
ReadCommentHandling = JsonCommentHandling.Skip,
|
||||
AllowTrailingCommas = true
|
||||
};
|
||||
|
||||
return JsonSerializer.Deserialize<Settings>(json, options);
|
||||
}
|
||||
}
|
||||
|
||||
public class GlobalSettings
|
||||
{
|
||||
public string? LogLevel { get; set; }
|
||||
}
|
||||
|
||||
public class DbSettings
|
||||
{
|
||||
public string? SqlServerDriver { get; set; }
|
||||
public string? Hostname { get; set; }
|
||||
public string? MgHostname { get; set; }
|
||||
public string? DbName { get; set; }
|
||||
public string? MgDbName { get; set; }
|
||||
public string? MysqlUsername { get; set; }
|
||||
public string? PgsqlUsername { get; set; }
|
||||
public string? MssqlUsername { get; set; }
|
||||
public string? MysqlPassword { get; set; }
|
||||
public string? PgsqlPassword { get; set; }
|
||||
public string? MssqlPassword { get; set; }
|
||||
public int PgsqlPort { get; set; }
|
||||
public int MysqlPort { get; set; }
|
||||
public int MssqlPort { get; set; }
|
||||
public int MgPort { get; set; }
|
||||
}
|
||||
|
||||
public class ApiSettings
|
||||
{
|
||||
public string? Type { get; set; }
|
||||
}
|
||||
|
||||
public class JsonSettings
|
||||
{
|
||||
public string? SeriesApi { get; set; }
|
||||
public string? ShowApi { get; set; }
|
||||
public string? EpisodeApi { get; set; }
|
||||
public string? AliasApi { get; set; }
|
||||
public string? CastApi { get; set; }
|
||||
public string? CrewApi { get; set; }
|
||||
public string? CreditsApi { get; set; }
|
||||
public string? UpdatesApi { get; set; }
|
||||
}
|
||||
|
||||
public class DatabaseSettings
|
||||
{
|
||||
public string? DbType { get; set; }
|
||||
public string? UpdateSchema { get; set; }
|
||||
public int Initialize { get; set; }
|
||||
public int InitLoad { get; set; }
|
||||
}
|
||||
|
||||
public class UpdateTypeSettings
|
||||
{
|
||||
public string? Type { get; set; }
|
||||
public string? Full { get; set; }
|
||||
public long Monthly { get; set; }
|
||||
public long Weekly { get; set; }
|
||||
public long Daily { get; set; }
|
||||
|
||||
[JsonPropertyName("12h")]
|
||||
public long H12 { get; set; }
|
||||
|
||||
[JsonPropertyName("6h")]
|
||||
public long H6 { get; set; }
|
||||
|
||||
public long Custom { get; set; }
|
||||
public int CacheSkip { get; set; }
|
||||
public int RefreshCache { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user