This commit is contained in:
2021-10-13 18:16:47 -04:00
parent d0ad783cfd
commit 2552ad4d87
3 changed files with 45 additions and 0 deletions

28
Web/Data/AppSettings.cs Normal file
View File

@@ -0,0 +1,28 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace Web.Data
{
public static class AppSettings
{
public static void Init(IConfiguration configuration)
{
var fields = typeof(AppSettings).GetProperties();
foreach (var propertyInfo in fields)
{
if (propertyInfo.PropertyType == typeof(string))
{
propertyInfo.SetValue(null, configuration.GetValue<string>(propertyInfo.Name));
}
else if (propertyInfo.PropertyType == typeof(int))
{
propertyInfo.SetValue(null, configuration.GetValue<int>(propertyInfo.Name));
}
else if (propertyInfo.PropertyType == typeof(double))
{
propertyInfo.SetValue(null, configuration.GetValue<double>(propertyInfo.Name));
}
}
}
}
}