AppSettings and Configuration changes,
major changes to E_Distance and minor for D_Face
This commit is contained in:
		| @ -1,4 +1,4 @@ | ||||
| using System.ComponentModel.DataAnnotations; | ||||
| using Microsoft.Extensions.Configuration; | ||||
| using System.Text.Json; | ||||
|  | ||||
| namespace View_by_Distance.Not.Copy.Copy.Models.Binder; | ||||
| @ -6,16 +6,13 @@ namespace View_by_Distance.Not.Copy.Copy.Models.Binder; | ||||
| public class AppSettings | ||||
| { | ||||
|  | ||||
|     [Display(Name = "Company"), Required] public string Company { get; set; } | ||||
|     [Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; } | ||||
|     [Display(Name = "Max Degree Of Parallelism"), Required] public int? MaxDegreeOfParallelism { get; set; } | ||||
| #nullable disable | ||||
|  | ||||
|     public AppSettings() | ||||
|     { | ||||
|         Company = string.Empty; | ||||
|         WorkingDirectoryName = string.Empty; | ||||
|         MaxDegreeOfParallelism = -1; | ||||
|     } | ||||
|     public string Company { get; set; } | ||||
|     public int? MaxDegreeOfParallelism { get; set; } | ||||
|     public string WorkingDirectoryName { get; set; } | ||||
|  | ||||
| #nullable restore | ||||
|  | ||||
|     public override string ToString() | ||||
|     { | ||||
| @ -23,4 +20,25 @@ public class AppSettings | ||||
|         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; | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user