Separate configuration settings

Added EAFLog
Testing Stratus file
This commit is contained in:
2023-11-16 15:15:58 -07:00
parent 0d6af37f89
commit 3f7b95c916
19 changed files with 494 additions and 388 deletions

View File

@ -8,9 +8,8 @@ public class AppSettings
public string? BuildNumber { get; set; }
public string? Company { get; set; }
public string? Destination { get; set; }
public string? GitCommitSeven { get; set; }
public bool? MatchPath { get; set; }
public string? Helper { get; set; }
public int? MillisecondsDelay { get; set; }
public string? WatchDirectory { get; set; }
@ -20,34 +19,68 @@ public class AppSettings
return result;
}
private static Models.AppSettings Get(AppSettings? appSettings)
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
{
if (appSettings?.BuildNumber is null)
{
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;
if (!physicalFileProvider.Root.Contains("UserSecrets"))
continue;
throw new NotSupportedException(physicalFileProvider.Root);
}
throw new NotSupportedException("Not Found!");
}
}
private static void Verify(AppSettings _)
{
}
private static Models.AppSettings Get(AppSettings? appSettings,
Models.EAFLogConfiguration eafLogConfiguration,
Models.StratusConfiguration stratusConfiguration,
Models.WaferCounterConfiguration waferCounterConfiguration)
{
Models.AppSettings result;
if (appSettings is null) throw new NullReferenceException(nameof(appSettings));
if (appSettings.BuildNumber is null) throw new NullReferenceException(nameof(BuildNumber));
if (appSettings.Company is null) throw new NullReferenceException(nameof(Company));
if (appSettings.Destination is null) throw new NullReferenceException(nameof(Destination));
if (appSettings.GitCommitSeven is null) throw new NullReferenceException(nameof(GitCommitSeven));
if (appSettings.MatchPath is null) throw new NullReferenceException(nameof(MatchPath));
if (appSettings.Helper is null) throw new NullReferenceException(nameof(Helper));
if (appSettings.MillisecondsDelay is null) throw new NullReferenceException(nameof(MillisecondsDelay));
if (appSettings.WatchDirectory is null) throw new NullReferenceException(nameof(WatchDirectory));
result = new(appSettings.BuildNumber,
Verify(appSettings);
result = new(eafLogConfiguration,
stratusConfiguration,
waferCounterConfiguration,
appSettings.BuildNumber,
appSettings.Company,
appSettings.Destination,
appSettings.GitCommitSeven,
appSettings.MatchPath.Value,
appSettings.Helper,
appSettings.MillisecondsDelay.Value,
appSettings.WatchDirectory);
return result;
}
public static Models.AppSettings Get(IConfiguration configuration)
public static Models.AppSettings Get(IConfigurationRoot configurationRoot,
Models.EAFLogConfiguration eafLogConfiguration,
Models.StratusConfiguration stratusConfiguration,
Models.WaferCounterConfiguration waferCounterConfiguration)
{
Models.AppSettings result;
#pragma warning disable IL3050, IL2026
AppSettings? appSettings = configuration.Get<AppSettings>();
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
#pragma warning restore IL3050, IL2026
result = Get(appSettings);
PreVerify(configurationRoot, appSettings);
result = Get(appSettings,
eafLogConfiguration,
stratusConfiguration,
waferCounterConfiguration);
return result;
}