using Microsoft.Extensions.Configuration; using System.Text.Json; namespace File_Folder_Helper.Models.Stateless; public abstract class AppSettings { public static Models.AppSettings Get(IConfigurationRoot configurationRoot) { Models.AppSettings? result; Binder.AppSettings appSettings = configurationRoot.Get(); string json = JsonSerializer.Serialize(appSettings, new JsonSerializerOptions() { WriteIndented = true }); result = JsonSerializer.Deserialize(json); if (result is null) throw new Exception(json); if (string.IsNullOrEmpty(result.Company)) throw new Exception(json); string jsonThis = result.ToString(); if (jsonThis != json) throw new Exception(json); return result; } }