Copy-Distinct

This commit is contained in:
Logan Phares
2023-06-11 15:10:26 -07:00
parent 0f6a78f242
commit 0d9bafe31e
12 changed files with 913 additions and 0 deletions

View File

@ -0,0 +1,48 @@
using Microsoft.Extensions.Configuration;
using System.Text.Json;
namespace View_by_Distance.Copy.Distinct.Models.Binder;
public class AppSettings
{
#nullable disable
public string Company { get; set; }
public string ComparePathsFile { get; set; }
public string CopyTo { get; set; }
public int? MaxDegreeOfParallelism { get; set; }
public string WorkingDirectoryName { get; set; }
#nullable restore
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?.MaxDegreeOfParallelism is null)
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
result = new(
appSettings.Company,
appSettings.ComparePathsFile,
appSettings.CopyTo,
appSettings.MaxDegreeOfParallelism.Value,
appSettings.WorkingDirectoryName
);
return result;
}
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
{
Models.AppSettings result;
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
result = Get(appSettings);
return result;
}
}