23 lines
869 B
C#
23 lines
869 B
C#
namespace ScoreboardApi.Extensions
|
|
{
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using Newtonsoft.Json;
|
|
using ScoreboardApi.Settings;
|
|
|
|
[ExcludeFromCodeCoverage]
|
|
public static class AppSettingsExtensions
|
|
{
|
|
public static void Verify<TApplicationSettings>(this ApplicationSettings appSettings)
|
|
where TApplicationSettings : ApplicationSettings
|
|
{
|
|
try
|
|
{
|
|
JsonConvert.DeserializeObject<TApplicationSettings>(JsonConvert.SerializeObject((object)appSettings));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(string.Format("There is a problem with the structure of the appsettings.json. Require sections or items may be missing or named incorrectly. Details: {0}", (object)ex.Message));
|
|
}
|
|
}
|
|
}
|
|
} |