-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfiguration.cs
54 lines (45 loc) · 1.29 KB
/
Configuration.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Java_Bytecode_Toolkit
{
public class Configuration
{
[JsonInclude]
public bool EnableLogging { get; set; } = false;
public static Configuration Open()
{
if (Directory.Exists(App.Current.CONFIG_DIR_FILE_PATH) == false)
{
Directory.CreateDirectory(App.Current.CONFIG_DIR_FILE_PATH);
}
if (File.Exists(App.Current.CONFIG_FILE_PATH) == false)
{
File.Create(App.Current.CONFIG_FILE_PATH).Close();
}
string configFileContents = File.ReadAllText(
App.Current.CONFIG_FILE_PATH
);
if (configFileContents == "")
{
return new Configuration();
}
return JsonSerializer.Deserialize<Configuration>(configFileContents);
}
public Configuration()
{
}
public void Save()
{
File.WriteAllText(
App.Current.CONFIG_FILE_PATH,
JsonSerializer.Serialize(this)
);
}
}
}