Merge Kristy Files
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Copy.Distinct.Models;
|
||||
|
||||
public record AppSettings(string Company,
|
||||
bool CopyDuplicates,
|
||||
string CopyTo,
|
||||
bool IfCanUseId,
|
||||
int MaxDegreeOfParallelism,
|
||||
string ResultDirectoryKey,
|
||||
string WorkingDirectoryName)
|
||||
@ -12,8 +14,14 @@ public record AppSettings(string Company,
|
||||
|
||||
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
|
||||
{
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Copy.Distinct.Models.Binder;
|
||||
|
||||
@ -7,15 +8,16 @@ public class AppSettings
|
||||
{
|
||||
|
||||
public string? Company { get; set; }
|
||||
public int? MaxDegreeOfParallelism { get; set; }
|
||||
public bool? CopyDuplicates { get; set; }
|
||||
public string? CopyTo { get; set; }
|
||||
public string? ResultDirectoryKey { init; get; }
|
||||
public bool? IfCanUseId { get; set; }
|
||||
public int? MaxDegreeOfParallelism { get; set; }
|
||||
public string? ResultDirectoryKey { get; set; }
|
||||
public string? WorkingDirectoryName { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
string result = JsonSerializer.Serialize(this, BinderAppSettingsSourceGenerationContext.Default.AppSettings);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -28,6 +30,8 @@ public class AppSettings
|
||||
throw new NullReferenceException(nameof(appSettings.CopyDuplicates));
|
||||
if (appSettings?.CopyTo is null)
|
||||
throw new NullReferenceException(nameof(appSettings.CopyTo));
|
||||
if (appSettings?.IfCanUseId is null)
|
||||
throw new NullReferenceException(nameof(appSettings.IfCanUseId));
|
||||
if (appSettings?.MaxDegreeOfParallelism is null)
|
||||
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
||||
if (appSettings?.ResultDirectoryKey is null)
|
||||
@ -38,6 +42,7 @@ public class AppSettings
|
||||
appSettings.Company,
|
||||
appSettings.CopyDuplicates.Value,
|
||||
appSettings.CopyTo,
|
||||
appSettings.IfCanUseId.Value,
|
||||
appSettings.MaxDegreeOfParallelism.Value,
|
||||
appSettings.ResultDirectoryKey,
|
||||
appSettings.WorkingDirectoryName
|
||||
@ -48,9 +53,17 @@ public class AppSettings
|
||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
#pragma warning disable IL3050, IL2026
|
||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||
#pragma warning restore IL3050, IL2026
|
||||
result = Get(appSettings);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||
[JsonSerializable(typeof(AppSettings))]
|
||||
internal partial class BinderAppSettingsSourceGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
||||
|
Reference in New Issue
Block a user