Created View Project
This commit is contained in:
		
							
								
								
									
										21
									
								
								View/Models/AppSettings.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								View/Models/AppSettings.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | ||||
| using System.Text.Json; | ||||
|  | ||||
| namespace OI.Metrology.View.Models; | ||||
|  | ||||
| public record AppSettings(string ApiUrl, | ||||
|                           string BuildNumber, | ||||
|                           string Company, | ||||
|                           string GitCommitSeven, | ||||
|                           bool IsDevelopment, | ||||
|                           bool IsStaging, | ||||
|                           string MonAResource, | ||||
|                           string MonASite) | ||||
| { | ||||
|  | ||||
|     public override string ToString() | ||||
|     { | ||||
|         string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true }); | ||||
|         return result; | ||||
|     } | ||||
|  | ||||
| } | ||||
							
								
								
									
										70
									
								
								View/Models/Binder/AppSettings.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								View/Models/Binder/AppSettings.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,70 @@ | ||||
| using Microsoft.Extensions.Configuration; | ||||
| using System.ComponentModel.DataAnnotations; | ||||
| using System.Text.Json; | ||||
|  | ||||
| namespace OI.Metrology.View.Models.Binder; | ||||
|  | ||||
| public class AppSettings | ||||
| { | ||||
|  | ||||
| #nullable disable | ||||
|  | ||||
|     [Display(Name = "Api Url"), Required] public string ApiUrl { get; set; } | ||||
|     [Display(Name = "Build Number"), Required] public string BuildNumber { get; set; } | ||||
|     [Display(Name = "Company"), Required] public string Company { get; set; } | ||||
|     [Display(Name = "Git Commit Seven"), Required] public string GitCommitSeven { get; set; } | ||||
|     [Display(Name = "Is Development"), Required] public bool? IsDevelopment { get; set; } | ||||
|     [Display(Name = "Is Staging"), Required] public bool? IsStaging { get; set; } | ||||
|     [Display(Name = "MonA Resource"), Required] public string MonAResource { get; set; } | ||||
|     [Display(Name = "MonA Site"), Required] public string MonASite { 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 is null) | ||||
|             throw new NullReferenceException(nameof(appSettings)); | ||||
|         if (appSettings.ApiUrl is null) | ||||
|             throw new NullReferenceException(nameof(ApiUrl)); | ||||
|         if (appSettings.BuildNumber is null) | ||||
|             throw new NullReferenceException(nameof(BuildNumber)); | ||||
|         if (appSettings.Company is null) | ||||
|             throw new NullReferenceException(nameof(Company)); | ||||
|         if (appSettings.GitCommitSeven is null) | ||||
|             throw new NullReferenceException(nameof(GitCommitSeven)); | ||||
|         if (appSettings.IsDevelopment is null) | ||||
|             throw new NullReferenceException(nameof(IsDevelopment)); | ||||
|         if (appSettings.IsStaging is null) | ||||
|             throw new NullReferenceException(nameof(IsStaging)); | ||||
|         if (appSettings.MonAResource is null) | ||||
|             throw new NullReferenceException(nameof(MonAResource)); | ||||
|         if (appSettings.MonASite is null) | ||||
|             throw new NullReferenceException(nameof(MonASite)); | ||||
|         result = new( | ||||
|             appSettings.ApiUrl, | ||||
|             appSettings.BuildNumber, | ||||
|             appSettings.Company, | ||||
|             appSettings.GitCommitSeven, | ||||
|             appSettings.IsDevelopment.Value, | ||||
|             appSettings.IsStaging.Value, | ||||
|             appSettings.MonAResource, | ||||
|             appSettings.MonASite); | ||||
|         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