Moved from ASP.Net to DTLib.Web, no more bloat!!!
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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:8080/";
|
||||
|
||||
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();
|
||||
}
|
||||
Reference in New Issue
Block a user