Mike Phares 229b508ae1 Dependency Injection Style
AOT Compiling
Switched to Secret from Development json file
Added Kanbn
Humanizer
HelperCreateNoteFiles.CleanExistingFiles
HelperPackageFilesByDate
Added SRP
Helper Hardcoded File Search and Sort
Set Date from Zip Entry
2023-07-08 10:05:52 -07:00

48 lines
1.6 KiB
C#

using Microsoft.Extensions.Configuration;
using System.Text.Json;
namespace File_Folder_Helper.Models.Binder;
public class AppSettings
{
public string? Company { get; set; }
public string? DefaultNoteType { get; set; }
public string[]? Exclude { get; set; }
public string? WorkingDirectoryName { get; set; }
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
private static Models.AppSettings Get(AppSettings? appSettings)
{
Models.AppSettings result;
if (appSettings?.Company is null)
throw new NullReferenceException(nameof(appSettings.Company));
if (appSettings?.DefaultNoteType is null)
throw new NullReferenceException(nameof(appSettings.DefaultNoteType));
if (appSettings?.Exclude is null)
throw new NullReferenceException(nameof(appSettings.Exclude));
if (appSettings?.WorkingDirectoryName is null)
throw new NullReferenceException(nameof(appSettings.WorkingDirectoryName));
result = new(
appSettings.Company,
appSettings.DefaultNoteType,
appSettings.Exclude,
appSettings.WorkingDirectoryName
);
return result;
}
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
{
Models.AppSettings result;
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
result = Get(appSettings);
return result;
}
}