Refactor
This commit is contained in:
@ -90,9 +90,7 @@ public class AppSettings
|
|||||||
Models.AppSettings? results;
|
Models.AppSettings? results;
|
||||||
string? json;
|
string? json;
|
||||||
if (appSettings is null || appSettings.ConfigurationFileName is null)
|
if (appSettings is null || appSettings.ConfigurationFileName is null)
|
||||||
json = null;
|
throw new NotSupportedException($"{nameof(appSettings.ConfigurationFileName)} must be set!");
|
||||||
else
|
|
||||||
{
|
|
||||||
string jsonFile = Path.Combine(AppContext.BaseDirectory, appSettings.ConfigurationFileName);
|
string jsonFile = Path.Combine(AppContext.BaseDirectory, appSettings.ConfigurationFileName);
|
||||||
if (File.Exists(jsonFile))
|
if (File.Exists(jsonFile))
|
||||||
json = File.ReadAllText(jsonFile);
|
json = File.ReadAllText(jsonFile);
|
||||||
@ -109,7 +107,6 @@ public class AppSettings
|
|||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(json) && File.Exists(jsonFile))
|
if (string.IsNullOrEmpty(json) && File.Exists(jsonFile))
|
||||||
json = File.ReadAllText(jsonFile);
|
json = File.ReadAllText(jsonFile);
|
||||||
}
|
|
||||||
results = (string.IsNullOrEmpty(json) ? null : results = JsonSerializer.Deserialize(json, AppSettingsSourceGenerationContext.Default.AppSettings)) ??
|
results = (string.IsNullOrEmpty(json) ? null : results = JsonSerializer.Deserialize(json, AppSettingsSourceGenerationContext.Default.AppSettings)) ??
|
||||||
throw new NullReferenceException(nameof(Models.AppSettings));
|
throw new NullReferenceException(nameof(Models.AppSettings));
|
||||||
results = Get(appSettings,
|
results = Get(appSettings,
|
||||||
|
Reference in New Issue
Block a user