2024-12-23 18:42:50 -05:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MxFilterGen2.JSON
|
|
|
|
|
{
|
|
|
|
|
internal class SETTINGS
|
|
|
|
|
{
|
2024-12-27 17:05:41 -05:00
|
|
|
|
public string dbHost { get; set; }
|
|
|
|
|
public string dbPort { get; set; }
|
|
|
|
|
public string dbName { get; set; }
|
|
|
|
|
public string dbUser { get; set; }
|
|
|
|
|
public string dbPass { get; set; }
|
2024-12-23 18:42:50 -05:00
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public bool Install { get; set; }
|
|
|
|
|
public List<string> Types { get; set; }
|
|
|
|
|
public List<string> Structures { get; set; }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class settings
|
|
|
|
|
{
|
2024-12-27 17:05:41 -05:00
|
|
|
|
public static string GetdbHost() => JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("settings.json")).dbHost;
|
|
|
|
|
public static string GetdbPort() => JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("settings.json")).dbPort;
|
|
|
|
|
public static string GetdbName() => JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("settings.json")).dbName;
|
|
|
|
|
public static string GetdbUser() => JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("settings.json")).dbUser;
|
|
|
|
|
public static string GetdbPass() => JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("settings.json")).dbPass;
|
2024-12-23 18:42:50 -05:00
|
|
|
|
internal static string GetName()
|
|
|
|
|
{
|
|
|
|
|
SETTINGS j = JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText($"settings.json"));
|
|
|
|
|
return j.Name;
|
|
|
|
|
}
|
|
|
|
|
internal static bool GetInstall()
|
|
|
|
|
{
|
|
|
|
|
SETTINGS j = JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText($"settings.json"));
|
|
|
|
|
return j.Install;
|
|
|
|
|
}
|
|
|
|
|
internal static List<string> GetType()
|
|
|
|
|
{
|
|
|
|
|
SETTINGS j = JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText($"settings.json"));
|
|
|
|
|
return j.Types;
|
|
|
|
|
}
|
|
|
|
|
internal static List<string> GetStructure()
|
|
|
|
|
{
|
|
|
|
|
SETTINGS j = JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText($"settings.json"));
|
|
|
|
|
return j.Structures;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void WriteSection(string structure)
|
|
|
|
|
{
|
|
|
|
|
SETTINGS js = JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText($"settings.json"));
|
|
|
|
|
SETTINGS se = new SETTINGS
|
|
|
|
|
{
|
|
|
|
|
Structures = js.Structures
|
|
|
|
|
};
|
|
|
|
|
var raw = JsonConvert.SerializeObject(se, Formatting.Indented);
|
|
|
|
|
File.WriteAllText($"settings.json", raw);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|