File tree Expand file tree Collapse file tree 6 files changed +58
-20
lines changed Expand file tree Collapse file tree 6 files changed +58
-20
lines changed Original file line number Diff line number Diff line change 180
180
< DefaultTestStubInNewModule> false< /DefaultTestStubInNewModule>
181
181
< /UnitTestSettings> </Value >
182
182
</Setting >
183
+ <Setting Name =" GeneralSettings" Type =" Rubberduck.Settings.GeneralSettings" Scope =" Application" >
184
+ <Value Profile =" (Default)" >< ?xml version="1.0" encoding="utf-16"?>
185
+ < GeneralSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
186
+ < Language Code="en-US" />
187
+ < CanShowSplash> true< /CanShowSplash>
188
+ < CanCheckVersion> true< /CanCheckVersion>
189
+ < IsSmartIndenterPrompted> false< /IsSmartIndenterPrompted>
190
+ < IsAutoSaveEnabled> false< /IsAutoSaveEnabled>
191
+ < AutoSavePeriod> 10< /AutoSavePeriod>
192
+ < MinimumLogLevel> 6< /MinimumLogLevel>
193
+ < EnableExperimentalFeatures />
194
+ < /GeneralSettings> </Value >
195
+ </Setting >
183
196
</Settings >
184
197
</SettingsFile >
Original file line number Diff line number Diff line change @@ -10,9 +10,11 @@ public class DisplayLanguageSetting
10
10
[ XmlAttribute ]
11
11
public string Code { get ; set ; }
12
12
13
+ /// <Summary>
14
+ /// Default constructor required for XML serialization.
15
+ /// </Summary>
13
16
public DisplayLanguageSetting ( )
14
17
{
15
- // serialization constructor
16
18
}
17
19
18
20
public DisplayLanguageSetting ( string code )
@@ -43,8 +45,7 @@ public DisplayLanguageSetting(string code)
43
45
44
46
public override bool Equals ( object obj )
45
47
{
46
- var other = obj as DisplayLanguageSetting ;
47
- return other != null && Code . Equals ( other . Code ) ;
48
+ return obj is DisplayLanguageSetting other && Code . Equals ( other . Code ) ;
48
49
}
49
50
50
51
public override int GetHashCode ( )
Original file line number Diff line number Diff line change @@ -7,16 +7,17 @@ public class GeneralConfigProvider : IConfigProvider<GeneralSettings>
7
7
{
8
8
private GeneralSettings _current ;
9
9
private readonly IPersistanceService < GeneralSettings > _persister ;
10
+ private readonly GeneralSettings _defaultSettings ;
10
11
11
12
public GeneralConfigProvider ( IPersistanceService < GeneralSettings > persister )
12
13
{
13
14
_persister = persister ;
15
+ _defaultSettings = new DefaultSettings < GeneralSettings > ( ) . Default ;
14
16
}
15
17
16
18
public GeneralSettings Create ( )
17
19
{
18
- var prototype = new GeneralSettings ( ) ;
19
- var updated = _persister . Load ( prototype ) ?? prototype ;
20
+ var updated = _persister . Load ( _defaultSettings ) ?? _defaultSettings ;
20
21
21
22
CheckForEventsToRaise ( updated ) ;
22
23
_current = updated ;
@@ -26,7 +27,7 @@ public GeneralSettings Create()
26
27
27
28
public GeneralSettings CreateDefaults ( )
28
29
{
29
- return new GeneralSettings ( ) ;
30
+ return _defaultSettings ;
30
31
}
31
32
32
33
public void Save ( GeneralSettings settings )
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Collections . Generic ;
3
+ using System . Configuration ;
3
4
using System . Linq ;
4
- using NLog ;
5
5
using System . Xml . Serialization ;
6
6
using Rubberduck . Common ;
7
7
@@ -19,6 +19,7 @@ public interface IGeneralSettings
19
19
List < ExperimentalFeatures > EnableExperimentalFeatures { get ; set ; }
20
20
}
21
21
22
+ [ SettingsSerializeAs ( SettingsSerializeAs . Xml ) ]
22
23
[ XmlType ( AnonymousType = true ) ]
23
24
public class GeneralSettings : IGeneralSettings , IEquatable < GeneralSettings >
24
25
{
@@ -50,19 +51,7 @@ public int MinimumLogLevel
50
51
}
51
52
}
52
53
53
- public List < ExperimentalFeatures > EnableExperimentalFeatures { get ; set ; }
54
-
55
- public GeneralSettings ( )
56
- {
57
- Language = new DisplayLanguageSetting ( "en-US" ) ;
58
- CanShowSplash = true ;
59
- CanCheckVersion = true ;
60
- IsSmartIndenterPrompted = false ;
61
- IsAutoSaveEnabled = false ;
62
- AutoSavePeriod = 10 ;
63
- MinimumLogLevel = LogLevel . Off . Ordinal ;
64
- EnableExperimentalFeatures = new List < ExperimentalFeatures > ( ) ;
65
- }
54
+ public List < ExperimentalFeatures > EnableExperimentalFeatures { get ; set ; } = new List < ExperimentalFeatures > ( ) ;
66
55
67
56
public bool Equals ( GeneralSettings other )
68
57
{
Original file line number Diff line number Diff line change 231
231
</UnitTestSettings >
232
232
</value >
233
233
</setting >
234
+ <setting name =" GeneralSettings" serializeAs =" Xml" >
235
+ <value >
236
+ <GeneralSettings xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
237
+ xmlns : xsd =" http://www.w3.org/2001/XMLSchema" >
238
+ <Language Code =" en-US" />
239
+ <CanShowSplash >true</CanShowSplash >
240
+ <CanCheckVersion >true</CanCheckVersion >
241
+ <IsSmartIndenterPrompted >false</IsSmartIndenterPrompted >
242
+ <IsAutoSaveEnabled >false</IsAutoSaveEnabled >
243
+ <AutoSavePeriod >10</AutoSavePeriod >
244
+ <MinimumLogLevel >6</MinimumLogLevel >
245
+ <EnableExperimentalFeatures />
246
+ </GeneralSettings >
247
+ </value >
248
+ </setting >
234
249
</Rubberduck .Properties.Settings>
235
250
</applicationSettings >
236
251
</configuration >
You can’t perform that action at this time.
0 commit comments