28 lines
940 B
C#
28 lines
940 B
C#
using Expose.MyIT.Shared.Models.Stateless;
|
|
using System.Text.Json;
|
|
|
|
namespace Expose.MyIT.Server.Models;
|
|
|
|
public class AppSettingsRepository : IAppSettingsRepository
|
|
{
|
|
|
|
private readonly AppSettings _AppSettings;
|
|
|
|
public AppSettingsRepository(AppSettings appSettings) => _AppSettings = appSettings;
|
|
|
|
public List<string> GetAppSettings()
|
|
{
|
|
List<string> results = new();
|
|
string json = JsonSerializer.Serialize(_AppSettings);
|
|
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
|
|
JsonProperty[] jsonProperties = jsonElement.EnumerateObject().ToArray();
|
|
foreach (JsonProperty jsonProperty in jsonProperties)
|
|
results.Add(jsonProperty.Value.ToString());
|
|
if (!_AppSettings.IsDevelopment)
|
|
throw new Exception("Shouldn't expose!");
|
|
return results;
|
|
}
|
|
|
|
List<string> IAppSettingsRepository.GetAppSettings() => GetAppSettings();
|
|
|
|
} |