-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHotKeyConfig.cs
More file actions
48 lines (40 loc) · 1.35 KB
/
Copy pathHotKeyConfig.cs
File metadata and controls
48 lines (40 loc) · 1.35 KB
1
using Newtonsoft.Json;using System.Collections.Generic;namespace NvkCommon{ public class HotKeyConfig { public const int SCHEMA_VERSION = 1; public static readonly string DEFAULT = @$"{{""SchemaVersion"":{SCHEMA_VERSION},""Sequence"":[]}}"; public int SchemaVersion { get; set; } public List<RawInputCapture.KeyEventInfo> Sequence { get; set; } public HotKeyConfig() { SchemaVersion = SCHEMA_VERSION; Sequence = []; } public HotKeyConfig(string json) { var config = JsonConvert.DeserializeObject<HotKeyConfig>(json) ?? new HotKeyConfig(); SchemaVersion = config.SchemaVersion; Sequence = config.Sequence; } public HotKeyConfig(List<RawInputCapture.KeyEventInfo> sequence) : this(SCHEMA_VERSION, sequence) { } private HotKeyConfig(int schemaVersion, List<RawInputCapture.KeyEventInfo> sequence) { SchemaVersion = schemaVersion; Sequence = sequence; } public override string ToString() { return $"{{SchemaVersion={SchemaVersion}, Sequence={Utils.ToString(Sequence)}}}"; } public string ToJson() { return JsonConvert.SerializeObject(this, Formatting.Indented); } }}