using Microsoft.Extensions.Configuration; using System.Text.Json; namespace Mesa_Backlog.Library.Binder; public class AppSettings { #nullable disable public Client Client { get; set; } public string Company { get; set; } public Excel Excel { get; set; } public string WorkingDirectoryName { get; set; } public string URLs { get; set; } #nullable restore public override string ToString() { string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true }); return result; } private static Library.AppSettings Get(AppSettings appSettings) { Library.AppSettings result; Library.Client client = new( appSettings.Client.API, appSettings.Client.BaseAddress, appSettings.Client.BasePage, appSettings.Client.PAT, appSettings.Client.Project, appSettings.Client.Query ); Library.Excel excel = new( appSettings.Excel.Sheet, appSettings.Excel.SourceFile, appSettings.Excel.TargetFile ); result = new( client, appSettings.Company, excel, appSettings.WorkingDirectoryName, appSettings.URLs ); return result; } public static Library.AppSettings Get(IConfigurationRoot configurationRoot) { Library.AppSettings result; AppSettings appSettings = configurationRoot.Get(); result = Get(appSettings); return result; } }