-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathSettings.cs
More file actions
62 lines (52 loc) · 1.7 KB
/
Copy pathSettings.cs
File metadata and controls
62 lines (52 loc) · 1.7 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
50
51
52
53
54
55
56
57
58
59
60
61
62
namespace Coder.Desktop.App.Models;
public interface ISettings<T> : ICloneable<T>
{
/// <summary>
/// FileName where the settings are stored.
/// </summary>
static abstract string SettingsFileName { get; }
/// <summary>
/// Gets the version of the settings schema.
/// </summary>
int Version { get; }
}
public interface ICloneable<T>
{
/// <summary>
/// Creates a deep copy of the settings object.
/// </summary>
/// <returns>A new instance of the settings object with the same values.</returns>
T Clone();
}
/// <summary>
/// CoderConnect settings class that holds the settings for the CoderConnect feature.
/// </summary>
public class CoderConnectSettings : ISettings<CoderConnectSettings>
{
public static string SettingsFileName { get; } = "coder-connect-settings.json";
public int Version { get; set; }
/// <summary>
/// When this is true, CoderConnect will automatically connect to the Coder VPN when the application starts.
/// </summary>
public bool ConnectOnLaunch { get; set; }
/// <summary>
/// CoderConnect current settings version. Increment this when the settings schema changes.
/// In future iterations we will be able to handle migrations when the user has
/// an older version.
/// </summary>
private const int VERSION = 1;
public CoderConnectSettings()
{
Version = VERSION;
ConnectOnLaunch = false;
}
public CoderConnectSettings(int? version, bool connectOnLaunch)
{
Version = version ?? VERSION;
ConnectOnLaunch = connectOnLaunch;
}
public CoderConnectSettings Clone()
{
return new CoderConnectSettings(Version, ConnectOnLaunch);
}
}