4
4
5
5
namespace RustBindFixer
6
6
{
7
- public class Settings
8
- {
9
- private static readonly object LoadLock ;
10
-
11
- public static Settings Instance { get ; private set ; }
12
-
13
- private const string SETTINGSFILE = "Settings.json" ;
14
-
15
- #region Properties
16
-
17
- public string KeysConfigPath { get ; set ; }
18
-
19
- public string LaunchParameters { get ; set ; }
20
-
21
- public List < Server > Servers { get ; set ; }
22
-
23
- #endregion Properties
24
-
25
- static Settings ( )
26
- {
27
- LoadLock = new object ( ) ;
28
- Instance = new Settings ( ) ;
29
- Load ( ) ;
30
- Save ( ) ;
31
- }
32
-
33
- public static void Save ( )
34
- {
35
- lock ( LoadLock )
36
- File . WriteAllText ( SETTINGSFILE , JsonConvert . SerializeObject ( Instance , Newtonsoft . Json . Formatting . Indented ) ) ;
37
- }
38
-
39
- public static void Load ( )
40
- {
41
- lock ( LoadLock )
42
- {
43
- if ( File . Exists ( SETTINGSFILE ) )
44
- Instance = JsonConvert . DeserializeObject < Settings > ( File . ReadAllText ( SETTINGSFILE ) ) ;
45
- }
46
- }
47
- }
7
+ public class Settings
8
+ {
9
+ private const string SETTINGSFILE = "Settings.json" ;
10
+ private static readonly object LoadLock ;
11
+
12
+ public static Settings Instance { get ; private set ; }
13
+
14
+ static Settings ( )
15
+ {
16
+ LoadLock = new object ( ) ;
17
+ Instance = new Settings ( ) ;
18
+ Load ( ) ;
19
+ Save ( ) ;
20
+ }
21
+
22
+ public static void Save ( )
23
+ {
24
+ lock ( LoadLock )
25
+ File . WriteAllText ( SETTINGSFILE , JsonConvert . SerializeObject ( Instance , Formatting . Indented ) ) ;
26
+ }
27
+
28
+ public static void Load ( )
29
+ {
30
+ lock ( LoadLock )
31
+ {
32
+ if ( File . Exists ( SETTINGSFILE ) )
33
+ {
34
+ var settings = new JsonSerializerSettings { ObjectCreationHandling = ObjectCreationHandling . Replace } ;
35
+ Instance = JsonConvert . DeserializeObject < Settings > ( File . ReadAllText ( SETTINGSFILE ) , settings ) ;
36
+ }
37
+ }
38
+ }
39
+
40
+ #region Properties
41
+
42
+ public string KeysConfigPath { get ; set ; } =
43
+ "C:\\ Program Files (x86)\\ Steam\\ steamapps\\ common\\ Rust\\ cfg\\ keys.cfg" ;
44
+
45
+ public string LaunchParameters { get ; set ; } = "-high -malloc=system -nolog" ;
46
+
47
+ public List < Server > Servers { get ; set ; } = new List < Server >
48
+ {
49
+ new Server
50
+ {
51
+ Name = "Example name" ,
52
+ Ip = "xxx.xxx.xxx.xxx:00000" ,
53
+ Description = "Example description" ,
54
+ PresentInServerList = false
55
+ }
56
+ } ;
57
+
58
+ #endregion Properties
59
+ }
48
60
}
0 commit comments