public static IConfigurationRoot Configuration { get; set; }
public static IConfigurationSection Datenbank { get; set; }
public static int Port { get; set; }
public static bool Https { get; set; }
public static dbclass
DB { get; set; }
public static void Load()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("config.json");
Configuration = builder.Build();
Port = Int32.Parse(Configuration["port"]);
Https = bool.Parse(Configuration["https"]);
//bis hier geht es aber danach kommt eine
Exception das der wert nicht vorhanden ist
Datenbank = Configuration.GetSection("datenbank");
DB.Port = Datenbank.GetValue<int>("port",3306);
DB.Server = Datenbank.GetValue<string>("server");
DB.Name = Datenbank.GetValue<string>("datenbank");
DB.Username = Datenbank.GetValue<string>("username");
DB.Password = Datenbank.GetValue<string>("password");
}