a
This commit is contained in:
@ -3,30 +3,22 @@ using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Set.Created.Date.Models;
|
||||
|
||||
public class AppSettings
|
||||
public record AppSettings(string Company,
|
||||
string CopyTo,
|
||||
int MaxDegreeOfParallelism,
|
||||
string WorkingDirectoryName)
|
||||
{
|
||||
|
||||
public string Company { init; get; }
|
||||
public string CopyTo { init; get; }
|
||||
public int MaxDegreeOfParallelism { init; get; }
|
||||
public string WorkingDirectoryName { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public AppSettings(string company,
|
||||
string copyTo,
|
||||
int maxDegreeOfParallelism,
|
||||
string workingDirectoryName)
|
||||
{
|
||||
Company = company;
|
||||
CopyTo = copyTo;
|
||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
||||
WorkingDirectoryName = workingDirectoryName;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
string result = JsonSerializer.Serialize(this, AppSettingsSourceGenerationContext.Default.AppSettings);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||
[JsonSerializable(typeof(AppSettings))]
|
||||
internal partial class AppSettingsSourceGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
2
Set-Created-Date/Models/Binder/.editorconfig
Normal file
2
Set-Created-Date/Models/Binder/.editorconfig
Normal file
@ -0,0 +1,2 @@
|
||||
[*.cs]
|
||||
csharp_preserve_single_line_statements = true
|
@ -1,6 +1,5 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Phares.Shared;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace View_by_Distance.Set.Created.Date.Models.Binder;
|
||||
@ -10,9 +9,9 @@ public class Configuration
|
||||
|
||||
#nullable disable
|
||||
|
||||
[Display(Name = "Ignore Extensions"), Required] public string[] IgnoreExtensions { get; set; }
|
||||
[Display(Name = "Property Configuration"), Required] public Property.Models.Configuration PropertyConfiguration { get; set; }
|
||||
[Display(Name = "Person Birthday Format"), Required] public string PersonBirthdayFormat { get; set; }
|
||||
public string[] IgnoreExtensions { get; set; }
|
||||
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
||||
public string PersonBirthdayFormat { get; set; }
|
||||
|
||||
#nullable restore
|
||||
|
||||
@ -25,12 +24,9 @@ public class Configuration
|
||||
private static Models.Configuration Get(Configuration? configuration)
|
||||
{
|
||||
Models.Configuration result;
|
||||
if (configuration is null)
|
||||
throw new NullReferenceException(nameof(configuration));
|
||||
if (configuration.IgnoreExtensions is null)
|
||||
throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||
if (configuration.PersonBirthdayFormat is null)
|
||||
throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||
result = new(
|
||||
configuration.IgnoreExtensions,
|
||||
configuration.PersonBirthdayFormat,
|
||||
|
Reference in New Issue
Block a user