34 lines
957 B
C#
34 lines
957 B
C#
using DTLib.Dtsod;
|
|
|
|
namespace ParadoxSaveParser.WebAPI;
|
|
|
|
public class Config
|
|
{
|
|
public const int ActualVersion = 1;
|
|
|
|
public int Version = ActualVersion;
|
|
public string BaseUrl = "http://127.0.0.1:5226/";
|
|
|
|
public static Config FromDtsod(DtsodV23 d)
|
|
{
|
|
var cfg = new Config
|
|
{
|
|
Version = d["version"],
|
|
BaseUrl = d["baseUrl"]
|
|
};
|
|
if (cfg.Version < ActualVersion)
|
|
throw new Exception($"config is obsolete (config v{cfg.Version} < program v{ActualVersion})");
|
|
if(cfg.Version > ActualVersion)
|
|
throw new Exception($"program is obsolete (config v{cfg.Version} > program v{ActualVersion})");
|
|
return cfg;
|
|
}
|
|
|
|
public DtsodV23 ToDtsod() =>
|
|
new()
|
|
{
|
|
{ "version", Version },
|
|
{ "baseUrl", BaseUrl },
|
|
};
|
|
|
|
public override string ToString() => ToDtsod().ToString();
|
|
} |