Mass push
This commit is contained in:
37
Duplicate-Search/Models/AppSettings.cs
Normal file
37
Duplicate-Search/Models/AppSettings.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Duplicate.Search.Models;
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
public string Company { init; get; }
|
||||
public bool IndexOnly { init; get; }
|
||||
public string[] IgnoreRelativePaths { init; get; }
|
||||
public int MaxDegreeOfParallelism { init; get; }
|
||||
public string OutputExtension { init; get; }
|
||||
public bool SortContainers { init; get; }
|
||||
public bool Reverse { init; get; }
|
||||
public string WorkingDirectoryName { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public AppSettings(string company, bool indexOnly, string[] ignoreRelativePaths, int maxDegreeOfParallelism, string outputExtension, bool sortContainers, bool reverse, string workingDirectoryName)
|
||||
{
|
||||
Company = company;
|
||||
IndexOnly = indexOnly;
|
||||
IgnoreRelativePaths = ignoreRelativePaths;
|
||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
||||
OutputExtension = outputExtension;
|
||||
SortContainers = sortContainers;
|
||||
Reverse = reverse;
|
||||
WorkingDirectoryName = workingDirectoryName;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
62
Duplicate-Search/Models/Binder/AppSettings.cs
Normal file
62
Duplicate-Search/Models/Binder/AppSettings.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace View_by_Distance.Duplicate.Search.Models.Binder;
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
#nullable disable
|
||||
|
||||
public string Company { get; set; }
|
||||
public bool? IndexOnly { get; set; }
|
||||
public string[] IgnoreRelativePaths { get; set; }
|
||||
public int? MaxDegreeOfParallelism { get; set; }
|
||||
public string OutputExtension { get; set; }
|
||||
public bool? SortContainers { get; set; }
|
||||
public bool? Reverse { 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?.IndexOnly is null)
|
||||
throw new NullReferenceException(nameof(appSettings.IndexOnly));
|
||||
if (appSettings?.IgnoreRelativePaths is null)
|
||||
throw new NullReferenceException(nameof(appSettings.IgnoreRelativePaths));
|
||||
if (appSettings?.MaxDegreeOfParallelism is null)
|
||||
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
||||
if (appSettings?.SortContainers is null)
|
||||
throw new NullReferenceException(nameof(appSettings.SortContainers));
|
||||
if (appSettings?.Reverse is null)
|
||||
throw new NullReferenceException(nameof(appSettings.Reverse));
|
||||
result = new(
|
||||
appSettings.Company,
|
||||
appSettings.IndexOnly.Value,
|
||||
appSettings.IgnoreRelativePaths,
|
||||
appSettings.MaxDegreeOfParallelism.Value,
|
||||
appSettings.OutputExtension,
|
||||
appSettings.SortContainers.Value,
|
||||
appSettings.Reverse.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;
|
||||
}
|
||||
|
||||
}
|
10
Duplicate-Search/Models/Stateless/SerilogExtensionMethods.cs
Normal file
10
Duplicate-Search/Models/Stateless/SerilogExtensionMethods.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace View_by_Distance.Duplicate.Search.Models.Stateless;
|
||||
|
||||
public static class SerilogExtensionMethods
|
||||
{
|
||||
|
||||
internal static void Warn(this Serilog.ILogger log, string messageTemplate) => log.Warning(messageTemplate);
|
||||
|
||||
internal static void Info(this Serilog.ILogger log, string messageTemplate) => log.Information(messageTemplate);
|
||||
|
||||
}
|
Reference in New Issue
Block a user