Delete-By-Distinct appSettings changes
This commit is contained in:
@ -1,37 +1,19 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Delete.By.Distinct.Models;
|
||||
|
||||
public class AppSettings
|
||||
public record AppSettings(string Company,
|
||||
string CompareRootDirectory,
|
||||
int MaxDegreeOfParallelism,
|
||||
string OutputExtension,
|
||||
bool RecycleOption,
|
||||
bool RenameToMatch,
|
||||
string SearchPattern,
|
||||
bool SizeForLong,
|
||||
bool TicksForLong,
|
||||
string WorkingDirectoryName)
|
||||
{
|
||||
|
||||
public string Company { init; get; }
|
||||
public string CompareRootDirectory { init; get; }
|
||||
public int MaxDegreeOfParallelism { init; get; }
|
||||
public string OutputExtension { init; get; }
|
||||
public bool RecycleOption { init; get; }
|
||||
public string SearchPattern { init; get; }
|
||||
public string WorkingDirectoryName { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public AppSettings(string company,
|
||||
string compareRootDirectory,
|
||||
int maxDegreeOfParallelism,
|
||||
string outputExtension,
|
||||
bool recycleOption,
|
||||
string searchPattern,
|
||||
string workingDirectoryName)
|
||||
{
|
||||
Company = company;
|
||||
CompareRootDirectory = compareRootDirectory;
|
||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
||||
OutputExtension = outputExtension;
|
||||
RecycleOption = recycleOption;
|
||||
SearchPattern = searchPattern;
|
||||
WorkingDirectoryName = workingDirectoryName;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
|
@ -13,7 +13,10 @@ public class AppSettings
|
||||
public int? MaxDegreeOfParallelism { get; set; }
|
||||
public string OutputExtension { get; set; }
|
||||
public bool? RecycleOption { get; set; }
|
||||
public bool? RenameToMatch { get; set; }
|
||||
public string SearchPattern { get; set; }
|
||||
public bool? SizeForLong { get; set; }
|
||||
public bool? TicksForLong { get; set; }
|
||||
public string WorkingDirectoryName { get; set; }
|
||||
|
||||
#nullable restore
|
||||
@ -31,13 +34,24 @@ public class AppSettings
|
||||
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
||||
if (appSettings?.RecycleOption is null)
|
||||
throw new NullReferenceException(nameof(appSettings.RecycleOption));
|
||||
if (appSettings?.RenameToMatch is null)
|
||||
throw new NullReferenceException(nameof(appSettings.RenameToMatch));
|
||||
if (appSettings?.SizeForLong is null)
|
||||
throw new NullReferenceException(nameof(appSettings.SizeForLong));
|
||||
if (appSettings?.TicksForLong is null)
|
||||
throw new NullReferenceException(nameof(appSettings.TicksForLong));
|
||||
if (appSettings.TicksForLong.Value == appSettings.SizeForLong.Value)
|
||||
throw new Exception("Check appSettings file!");
|
||||
result = new(
|
||||
appSettings.Company,
|
||||
appSettings.CompareRootDirectory,
|
||||
appSettings.MaxDegreeOfParallelism.Value,
|
||||
appSettings.OutputExtension,
|
||||
appSettings.RecycleOption.Value,
|
||||
appSettings.RenameToMatch.Value,
|
||||
appSettings.SearchPattern,
|
||||
appSettings.SizeForLong.Value,
|
||||
appSettings.TicksForLong.Value,
|
||||
appSettings.WorkingDirectoryName
|
||||
);
|
||||
return result;
|
||||
|
Reference in New Issue
Block a user