Ready to test

This commit is contained in:
2022-05-26 08:57:57 -07:00
parent e5df7f743e
commit 0987ee8b80
28 changed files with 1747 additions and 2 deletions

View File

@ -0,0 +1,25 @@
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<Binder.AppSettings>();
string json = JsonSerializer.Serialize(appSettings, new JsonSerializerOptions() { WriteIndented = true });
result = JsonSerializer.Deserialize<Models.AppSettings>(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;
}
}