Files
.config
.vscode
Client
Server
.vscode
Controllers
Data
Models
Binder
AppSettings.cs
AppSettingsRepository.cs
ClientSettingsRepository.cs
ServiceShopOrderRepository.cs
SsaOrderRepository.cs
Pages
Sample-Data
Expose-MyIT.Server.csproj
Program.cs
appsettings.Development.json
appsettings.Staging.json
appsettings.json
Shared
Tests
.editorconfig
.gitignore
Expose-MyIT.sln
ReadMe.md
expose-myit/Server/Models/AppSettingsRepository.cs

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();
}