10
10
// This program is distributed in the hope that it will be useful,
11
11
// but WITHOUT ANY WARRANTY
12
12
// </copyright>
13
-
13
+ #nullable enable
14
14
using System ;
15
15
using System . Collections . Generic ;
16
16
using System . Collections . Specialized ;
@@ -44,10 +44,10 @@ public static class ConfigFactory
44
44
45
45
private static readonly SemaphoreSlim _semaphore = new ( 1 , 1 ) ;
46
46
47
- public delegate void ConfigurationUpdateEventHandler ( string key , object oldValue , object newValue ) ;
47
+ public delegate void ConfigurationUpdateEventHandler ( string key , object ? oldValue , object ? newValue ) ;
48
48
49
49
// ReSharper disable once EventNeverSubscribedTo.Global
50
- public static event ConfigurationUpdateEventHandler ConfigurationUpdateEvent ;
50
+ public static event ConfigurationUpdateEventHandler ? ConfigurationUpdateEvent ;
51
51
52
52
private static readonly JsonSerializerOptions _options = new ( ) { WriteIndented = true , Converters = { new JsonStringEnumConverter ( ) } , Encoder = JavaScriptEncoder . Create ( UnicodeRanges . BasicLatin , UnicodeRanges . CjkUnifiedIdeographs , UnicodeRanges . CjkSymbolsandPunctuation , UnicodeRanges . HalfwidthandFullwidthForms ) , DefaultIgnoreCondition = JsonIgnoreCondition . WhenWritingNull } ;
53
53
@@ -61,7 +61,7 @@ public static class ConfigFactory
61
61
Directory . CreateDirectory ( "config" ) ;
62
62
}
63
63
64
- Root parsed = null ;
64
+ Root ? parsed = null ;
65
65
if ( File . Exists ( _configurationFile ) )
66
66
{
67
67
try
@@ -195,7 +195,7 @@ void SpecificConfigBind(string name, SpecificConfig config)
195
195
}
196
196
} ) ;
197
197
198
- private static PropertyChangedEventHandler OnPropertyChangedFactory ( string key , object oldValue , object newValue )
198
+ private static PropertyChangedEventHandler OnPropertyChangedFactory ( string key , object ? oldValue , object ? newValue )
199
199
{
200
200
return ( o , args ) =>
201
201
{
@@ -213,7 +213,7 @@ private static PropertyChangedEventHandler OnPropertyChangedFactory(string key =
213
213
{
214
214
return ( o , args ) =>
215
215
{
216
- object after = null ;
216
+ object ? after = null ;
217
217
if ( args is PropertyChangedEventDetailArgs detailArgs )
218
218
{
219
219
after = detailArgs . NewValue ;
@@ -236,7 +236,7 @@ private static NotifyCollectionChangedEventHandler<KeyValuePair<T1, T2>> OnColle
236
236
237
237
public static readonly SpecificConfig CurrentConfig = Root . CurrentConfig ;
238
238
239
- private static async void OnPropertyChanged ( string key , object oldValue , object newValue )
239
+ private static async void OnPropertyChanged ( string key , object ? oldValue , object ? newValue )
240
240
{
241
241
var result = await SaveAsync ( ) ;
242
242
if ( result )
@@ -250,7 +250,7 @@ private static async void OnPropertyChanged(string key, object oldValue, object
250
250
}
251
251
}
252
252
253
- private static bool Save ( string file = null )
253
+ private static bool Save ( string ? file = null )
254
254
{
255
255
lock ( _lock )
256
256
{
@@ -268,7 +268,7 @@ private static bool Save(string file = null)
268
268
}
269
269
}
270
270
271
- private static async Task < bool > SaveAsync ( string file = null )
271
+ private static async Task < bool > SaveAsync ( string ? file = null )
272
272
{
273
273
await _semaphore . WaitAsync ( ) ;
274
274
try
@@ -325,7 +325,7 @@ public static bool SwitchConfig(string configName)
325
325
return true ;
326
326
}
327
327
328
- public static bool AddConfiguration ( string configName , string copyFrom = null )
328
+ public static bool AddConfiguration ( string configName , string ? copyFrom = null )
329
329
{
330
330
if ( string . IsNullOrEmpty ( configName ) )
331
331
{
0 commit comments