Files
API/TOOHUCardAPI/Data/AppSettings.cs

38 lines
1.5 KiB
C#

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace TOOHUCardAPI.Data
{
public static class AppSettings
{
public static int PointsPerLevel { get; set; }
public static int PointsPerLevelNormal { get; set; }
public static int FirstWinBonusPointsMin { get; set; }
public static int FirstWinBonusPointsMax { get; set; }
public static int MaxPhoenixSpirits { get; set; }
public static int PointsPerKey { get; set; }
public static int MaxKeyPurchaseAmount { get; set; }
public static string StarterDeckGroupKey { get; set; }
public static string StarterDeckGroupData { get; set; }
public static int DefaultRankBonus { get; set; }
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));
}
}
}
}
}