-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppConfig.cs
42 lines (38 loc) · 1.06 KB
/
AppConfig.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
using System;
using System.IO;
using Newtonsoft.Json;
namespace RoundedWindowsEdges
{
public class AppConfig
{
public int CornerSize { get; set; } = 20;
private static readonly string configFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.json");
public static AppConfig LoadConfig()
{
if (File.Exists(configFilePath))
{
try
{
string json = File.ReadAllText(configFilePath);
return JsonConvert.DeserializeObject<AppConfig>(json);
}
catch
{
return new AppConfig();
}
}
return new AppConfig();
}
public void SaveConfig()
{
try
{
string json = JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
File.WriteAllText(configFilePath, json);
}
catch
{
}
}
}
}