-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig.cs
73 lines (61 loc) · 1.96 KB
/
Config.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Alarm_v2
{
public class Config
{
internal static JsonSerializerOptions serializerOptions = new()
{
IncludeFields = true,
WriteIndented = true,
AllowTrailingCommas = true,
ReadCommentHandling = JsonCommentHandling.Skip,
UnmappedMemberHandling = JsonUnmappedMemberHandling.Skip,
};
public required string playlist;
public required Guid device;
public int volume = -1;
public string? pb;
public bool pl = false;
public string[] pfx = [];
public string? log;
public ExperimentalOptions? opts;
public FileInfo PlayList() => new(playlist);
public FileInfo? PBFile() => pb is null ? null : new(pb);
public FileInfo? LogFile() => log is null ? null : new(log);
public Shell? shell = null;
public ExtraContent[] extra = [];
public Dictionary<string, string> mapping = [];
public Config() { }
public static Config? Deserialize(FileInfo file)
{
var fs = file.OpenRead();
return JsonSerializer.Deserialize<Config>(fs, serializerOptions);
}
public string Serialize()
{
return JsonSerializer.Serialize(this, serializerOptions);
}
public List<string> GetExtraContent()
{
List<string> content = [];
foreach (var item in extra)
{
bool chr;
foreach(var l in item.GetContent(shell ?? NullShell.Shared, out chr))
{
content.Add(l);
}
if(chr && item.stopIfTrue)
{
break;
}
}
return content;
}
public class ExperimentalOptions
{
public bool memstream = false;
}
}
}