-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSettings.cs
More file actions
49 lines (44 loc) · 1.3 KB
/
Settings.cs
File metadata and controls
49 lines (44 loc) · 1.3 KB
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
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace ToolWindow
{
[JsonObject(MemberSerialization.OptIn)]
public class Settings
{
[JsonProperty("autoCapture")]
public bool AutoCapture { get; set; }
[JsonProperty("breakPoints")]
public List<string> BreakPoints{ get; set; }
public static Settings FromFile(string settingsFilePath)
{
if (File.Exists(settingsFilePath))
{
try
{
string jsonString = File.ReadAllText(settingsFilePath);
return JObject.Parse(jsonString).ToObject<Settings>();
}
catch
{
}
}
return new Settings()
{
BreakPoints = new List<string>()
};
}
public void SaveSettings(string settingsFilePath)
{
try
{
string jsonString = JsonConvert.SerializeObject(this, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore });
File.WriteAllText(settingsFilePath, jsonString);
}
catch
{
}
}
}
}