- Include root in valid directories
- AppSetting bug fix - Updated testes with base test class and editor configuration changes - Created new server and wafer counter tasks json files and pipelines to match
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace OI.Metrology.Server.Models;
|
||||
|
||||
@ -36,8 +37,75 @@ public record AppSettings(string ApiFileShare,
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
string result = JsonSerializer.Serialize(this, AppSettingsSourceGenerationContext.Default.AppSettings);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void Verify(AppSettings appSettings)
|
||||
{
|
||||
if (string.IsNullOrEmpty(appSettings.Company))
|
||||
throw new Exception("Company name must have a value!");
|
||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||
throw new Exception("Working directory name must have a value!");
|
||||
}
|
||||
|
||||
public static AppSettings Get(IConfigurationRoot configurationRoot)
|
||||
{
|
||||
AppSettings result;
|
||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||
#pragma warning restore IL3050, IL2026
|
||||
if (appSettings is null
|
||||
|| appSettings?.Company is null)
|
||||
{
|
||||
List<string> paths = [];
|
||||
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
||||
{
|
||||
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
|
||||
continue;
|
||||
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
|
||||
continue;
|
||||
paths.Add(physicalFileProvider.Root);
|
||||
}
|
||||
throw new NotSupportedException($"Not found!{Environment.NewLine}{string.Join(Environment.NewLine, paths.Distinct())}");
|
||||
}
|
||||
result = new(appSettings.ApiFileShare,
|
||||
appSettings.ApiLoggingContentTypes,
|
||||
appSettings.ApiLoggingPathPrefixes,
|
||||
appSettings.ApiLogPath,
|
||||
appSettings.ApiUrl,
|
||||
appSettings.BuildNumber,
|
||||
appSettings.Company,
|
||||
appSettings.ConnectionString,
|
||||
appSettings.EcCharacterizationSi,
|
||||
appSettings.EcMesaFileShareCharacterizationSi,
|
||||
appSettings.EcMesaFileShareMetrologySi,
|
||||
appSettings.EcMetrologySi,
|
||||
appSettings.GitCommitSeven,
|
||||
appSettings.InboundApiAllowedIPList,
|
||||
appSettings.IqsColumns,
|
||||
appSettings.IqsFileSegments,
|
||||
appSettings.IqsKey,
|
||||
appSettings.IqsRed,
|
||||
appSettings.IqsYellow,
|
||||
appSettings.IsDevelopment,
|
||||
appSettings.IsStaging,
|
||||
appSettings.MockRoot,
|
||||
appSettings.MonAResource,
|
||||
appSettings.MonASite,
|
||||
appSettings.OpenInsightApplicationProgrammingInterface,
|
||||
appSettings.TableToPath,
|
||||
appSettings.URLs,
|
||||
appSettings.WaferCounterDestinationDirectory,
|
||||
appSettings.WaferCounterTwoFileSecondsWait,
|
||||
appSettings.WorkingDirectoryName);
|
||||
Verify(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||
[JsonSerializable(typeof(AppSettings))]
|
||||
public partial class AppSettingsSourceGenerationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user