Drag-Drop-Explorer
This commit is contained in:
27
Drag-Drop-Explorer/Models/AppSettings.cs
Normal file
27
Drag-Drop-Explorer/Models/AppSettings.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Drag_Drop_Explorer.Models;
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
public string Company { init; get; }
|
||||
public int MaxDegreeOfParallelism { init; get; }
|
||||
public string WorkingDirectoryName { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public AppSettings(string company, int maxDegreeOfParallelism, string workingDirectoryName)
|
||||
{
|
||||
Company = company;
|
||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
||||
WorkingDirectoryName = workingDirectoryName;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
44
Drag-Drop-Explorer/Models/Binder/AppSettings.cs
Normal file
44
Drag-Drop-Explorer/Models/Binder/AppSettings.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace View_by_Distance.Drag_Drop_Explorer.Models.Binder;
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
#nullable disable
|
||||
|
||||
public string Company { 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.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;
|
||||
}
|
||||
|
||||
}
|
4
Drag-Drop-Explorer/Models/MatchNginx.cs
Normal file
4
Drag-Drop-Explorer/Models/MatchNginx.cs
Normal file
@ -0,0 +1,4 @@
|
||||
namespace View_by_Distance.Drag_Drop_Explorer;
|
||||
|
||||
public record MatchNginx(string Name, string Type, DateTime MTime, long Size, string ConvertedPath)
|
||||
{ }
|
Reference in New Issue
Block a user