PreVerify
This commit is contained in:
parent
368138bb78
commit
61d1ae71f6
@ -20,6 +20,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -36,7 +53,10 @@ public class AppSettings
|
|||||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ namespace View_by_Distance.Compare.Models.Binder;
|
|||||||
public class Configuration
|
public class Configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
public string DiffPropertyDirectory { get; set; }
|
public string DiffPropertyDirectory { get; set; }
|
||||||
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
||||||
public string[] Rename { get; set; }
|
public string[] Rename { get; set; }
|
||||||
@ -13,8 +12,6 @@ public class Configuration
|
|||||||
public string[] RenameC { get; set; }
|
public string[] RenameC { get; set; }
|
||||||
public string[] Spelling { get; set; }
|
public string[] Spelling { get; set; }
|
||||||
|
|
||||||
#nullable restore
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||||
|
@ -21,6 +21,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -56,6 +73,7 @@ public class AppSettings
|
|||||||
#pragma warning disable IL3050, IL2026
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
#pragma warning restore IL3050, IL2026
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,9 @@ namespace View_by_Distance.Copy.Distinct.Models.Binder;
|
|||||||
public class Configuration
|
public class Configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
#nullable disable
|
public string[]? IgnoreExtensions { get; set; }
|
||||||
|
public Property.Models.Configuration? PropertyConfiguration { get; set; }
|
||||||
public string[] IgnoreExtensions { get; set; }
|
public string? PersonBirthdayFormat { get; set; }
|
||||||
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
|
||||||
public string PersonBirthdayFormat { get; set; }
|
|
||||||
|
|
||||||
#nullable restore
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
@ -21,12 +17,30 @@ public class Configuration
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, Configuration? configuration)
|
||||||
|
{
|
||||||
|
if (configuration?.IgnoreExtensions 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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||||
|
if (configuration.PropertyConfiguration is null) throw new NullReferenceException(nameof(configuration.PropertyConfiguration));
|
||||||
result = new(
|
result = new(
|
||||||
configuration.IgnoreExtensions,
|
configuration.IgnoreExtensions,
|
||||||
configuration.PersonBirthdayFormat,
|
configuration.PersonBirthdayFormat,
|
||||||
@ -39,14 +53,19 @@ public class Configuration
|
|||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
Configuration? configuration;
|
Configuration? configuration;
|
||||||
if (isEnvironment is null)
|
if (isEnvironment is null)
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationRoot.Get<Configuration>();
|
configuration = configurationRoot.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||||
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
||||||
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationSection.Get<Configuration>();
|
configuration = configurationSection.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
}
|
}
|
||||||
|
PreVerify(configurationRoot, configuration);
|
||||||
result = Get(configuration);
|
result = Get(configuration);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -36,7 +53,10 @@ public class AppSettings
|
|||||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -7,17 +7,13 @@ namespace View_by_Distance.Date.Group.Models.Binder;
|
|||||||
public class Configuration
|
public class Configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
public bool? ByCreateDateShortcut { get; set; }
|
public bool? ByCreateDateShortcut { get; set; }
|
||||||
public bool? ByDay { get; set; }
|
public bool? ByDay { get; set; }
|
||||||
public bool? ByHash { get; set; }
|
public bool? ByHash { get; set; }
|
||||||
public bool? BySeason { get; set; }
|
public bool? BySeason { get; set; }
|
||||||
public bool? ByWeek { get; set; }
|
public bool? ByWeek { get; set; }
|
||||||
public bool? KeepFullPath { get; set; }
|
public bool? KeepFullPath { get; set; }
|
||||||
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
public Property.Models.Configuration? PropertyConfiguration { get; set; }
|
||||||
|
|
||||||
#nullable restore
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
@ -25,10 +21,28 @@ public class Configuration
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, Configuration? configuration)
|
||||||
|
{
|
||||||
|
if (configuration?.ByCreateDateShortcut 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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
|
if (configuration.PropertyConfiguration is null) throw new NullReferenceException(nameof(configuration.PropertyConfiguration));
|
||||||
if (configuration.ByCreateDateShortcut is null) throw new NullReferenceException(nameof(configuration.ByCreateDateShortcut));
|
if (configuration.ByCreateDateShortcut is null) throw new NullReferenceException(nameof(configuration.ByCreateDateShortcut));
|
||||||
if (configuration.ByDay is null) throw new NullReferenceException(nameof(configuration.ByDay));
|
if (configuration.ByDay is null) throw new NullReferenceException(nameof(configuration.ByDay));
|
||||||
if (configuration.ByHash is null) throw new NullReferenceException(nameof(configuration.ByHash));
|
if (configuration.ByHash is null) throw new NullReferenceException(nameof(configuration.ByHash));
|
||||||
@ -51,16 +65,20 @@ public class Configuration
|
|||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
Configuration? configuration;
|
Configuration? configuration;
|
||||||
if (isEnvironment is null)
|
if (isEnvironment is null)
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationRoot.Get<Configuration>();
|
configuration = configurationRoot.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||||
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
||||||
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationSection.Get<Configuration>();
|
configuration = configurationSection.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
}
|
}
|
||||||
|
PreVerify(configurationRoot, configuration);
|
||||||
result = Get(configuration);
|
result = Get(configuration);
|
||||||
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -58,7 +75,10 @@ public class AppSettings
|
|||||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -40,7 +57,10 @@ public class AppSettings
|
|||||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -36,7 +53,10 @@ public class AppSettings
|
|||||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ public class Program
|
|||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
private static void Main()
|
||||||
{
|
{
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new DragDropExplorer());
|
Application.Run(new DragDropExplorer());
|
||||||
|
@ -16,6 +16,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -36,7 +53,10 @@ public class AppSettings
|
|||||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ public class Program
|
|||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
private static void Main()
|
||||||
{
|
{
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new DragDropMove());
|
Application.Run(new DragDropMove());
|
||||||
|
@ -20,6 +20,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -36,7 +53,10 @@ public class AppSettings
|
|||||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,6 @@ namespace View_by_Distance.Drag_Drop.Models.Binder;
|
|||||||
public class Configuration
|
public class Configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
public bool? CheckDFaceAndUpWriteDates { get; set; }
|
public bool? CheckDFaceAndUpWriteDates { get; set; }
|
||||||
public bool? CheckJsonForDistanceResults { get; set; }
|
public bool? CheckJsonForDistanceResults { get; set; }
|
||||||
public int? CrossDirectoryMaxItemsInDistanceCollection { get; set; }
|
public int? CrossDirectoryMaxItemsInDistanceCollection { get; set; }
|
||||||
@ -16,40 +14,38 @@ public class Configuration
|
|||||||
public bool? ForceFaceLastWriteTimeToCreationTime { get; set; }
|
public bool? ForceFaceLastWriteTimeToCreationTime { get; set; }
|
||||||
public bool? ForceMetadataLastWriteTimeToCreationTime { get; set; }
|
public bool? ForceMetadataLastWriteTimeToCreationTime { get; set; }
|
||||||
public bool? ForceResizeLastWriteTimeToCreationTime { get; set; }
|
public bool? ForceResizeLastWriteTimeToCreationTime { get; set; }
|
||||||
public string[] IgnoreExtensions { get; set; }
|
public string[]? IgnoreExtensions { get; set; }
|
||||||
public string[] JLinks { get; set; }
|
public string[]? JLinks { get; set; }
|
||||||
public string[] LoadOrCreateThenSaveDistanceResultsForOutputResolutions { get; set; }
|
public string[]? LoadOrCreateThenSaveDistanceResultsForOutputResolutions { get; set; }
|
||||||
public string[] LoadOrCreateThenSaveImageFacesResultsForOutputResolutions { get; set; }
|
public string[]? LoadOrCreateThenSaveImageFacesResultsForOutputResolutions { get; set; }
|
||||||
public string[] MixedYearRelativePaths { get; set; }
|
public string[]? MixedYearRelativePaths { get; set; }
|
||||||
public string ModelDirectory { get; set; }
|
public string? ModelDirectory { get; set; }
|
||||||
public string ModelName { get; set; }
|
public string? ModelName { get; set; }
|
||||||
public int? NumberOfJitters { get; set; }
|
public int? NumberOfJitters { get; set; }
|
||||||
public int? NumberOfTimesToUpsample { get; set; }
|
public int? NumberOfTimesToUpsample { get; set; }
|
||||||
public string OutputExtension { get; set; }
|
public string? OutputExtension { get; set; }
|
||||||
public int? OutputQuality { get; set; }
|
public int? OutputQuality { get; set; }
|
||||||
public string[] OutputResolutions { get; set; }
|
public string[]? OutputResolutions { get; set; }
|
||||||
public bool? OverrideForFaceImages { get; set; }
|
public bool? OverrideForFaceImages { get; set; }
|
||||||
public bool? OverrideForFaceLandmarkImages { get; set; }
|
public bool? OverrideForFaceLandmarkImages { get; set; }
|
||||||
public bool? OverrideForResizeImages { get; set; }
|
public bool? OverrideForResizeImages { get; set; }
|
||||||
public string PersonBirthdayFormat { get; set; }
|
public string? PersonBirthdayFormat { get; set; }
|
||||||
public string PredictorModelName { get; set; }
|
public string? PredictorModelName { get; set; }
|
||||||
public bool? PropertiesChangedForDistance { get; set; }
|
public bool? PropertiesChangedForDistance { get; set; }
|
||||||
public bool? PropertiesChangedForFaces { get; set; }
|
public bool? PropertiesChangedForFaces { get; set; }
|
||||||
public bool? PropertiesChangedForIndex { get; set; }
|
public bool? PropertiesChangedForIndex { get; set; }
|
||||||
public bool? PropertiesChangedForMetadata { get; set; }
|
public bool? PropertiesChangedForMetadata { get; set; }
|
||||||
public bool? PropertiesChangedForResize { get; set; }
|
public bool? PropertiesChangedForResize { get; set; }
|
||||||
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
public Property.Models.Configuration? PropertyConfiguration { get; set; }
|
||||||
public bool? Reverse { get; set; }
|
public bool? Reverse { get; set; }
|
||||||
public string[] SaveFaceLandmarkForOutputResolutions { get; set; }
|
public string[]? SaveFaceLandmarkForOutputResolutions { get; set; }
|
||||||
public bool? SaveFullYearOfRandomFiles { get; set; }
|
public bool? SaveFullYearOfRandomFiles { get; set; }
|
||||||
public string[] SaveFilteredOriginalImagesFromJLinksForOutputResolutions { get; set; }
|
public string[]? SaveFilteredOriginalImagesFromJLinksForOutputResolutions { get; set; }
|
||||||
public string[] SaveShortcutsForOutputResolutions { get; set; }
|
public string[]? SaveShortcutsForOutputResolutions { get; set; }
|
||||||
public bool? SaveResizedSubfiles { get; set; }
|
public bool? SaveResizedSubfiles { get; set; }
|
||||||
public bool? SkipSearch { get; set; }
|
public bool? SkipSearch { get; set; }
|
||||||
public bool? TestDistanceResults { get; set; }
|
public bool? TestDistanceResults { get; set; }
|
||||||
public string[] ValidResolutions { get; set; }
|
public string[]? ValidResolutions { get; set; }
|
||||||
|
|
||||||
#nullable restore
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
@ -57,10 +53,28 @@ public class Configuration
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, Configuration? configuration)
|
||||||
|
{
|
||||||
|
if (configuration?.CheckDFaceAndUpWriteDates 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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
|
if (configuration.PropertyConfiguration is null) throw new NullReferenceException(nameof(configuration.PropertyConfiguration));
|
||||||
if (configuration.CheckDFaceAndUpWriteDates is null) throw new NullReferenceException(nameof(configuration.CheckDFaceAndUpWriteDates));
|
if (configuration.CheckDFaceAndUpWriteDates is null) throw new NullReferenceException(nameof(configuration.CheckDFaceAndUpWriteDates));
|
||||||
if (configuration.CheckJsonForDistanceResults is null) throw new NullReferenceException(nameof(configuration.CheckJsonForDistanceResults));
|
if (configuration.CheckJsonForDistanceResults is null) throw new NullReferenceException(nameof(configuration.CheckJsonForDistanceResults));
|
||||||
if (configuration.CrossDirectoryMaxItemsInDistanceCollection is null) throw new NullReferenceException(nameof(configuration.CrossDirectoryMaxItemsInDistanceCollection));
|
if (configuration.CrossDirectoryMaxItemsInDistanceCollection is null) throw new NullReferenceException(nameof(configuration.CrossDirectoryMaxItemsInDistanceCollection));
|
||||||
@ -68,18 +82,23 @@ public class Configuration
|
|||||||
if (configuration.ForceFaceLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForceFaceLastWriteTimeToCreationTime));
|
if (configuration.ForceFaceLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForceFaceLastWriteTimeToCreationTime));
|
||||||
if (configuration.ForceMetadataLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForceMetadataLastWriteTimeToCreationTime));
|
if (configuration.ForceMetadataLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForceMetadataLastWriteTimeToCreationTime));
|
||||||
if (configuration.ForceResizeLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForceResizeLastWriteTimeToCreationTime));
|
if (configuration.ForceResizeLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForceResizeLastWriteTimeToCreationTime));
|
||||||
|
if (configuration.JLinks is null) throw new NullReferenceException(nameof(configuration.JLinks));
|
||||||
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions ??= [];
|
configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions ??= [];
|
||||||
configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions ??= [];
|
configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions ??= [];
|
||||||
if (configuration.MixedYearRelativePaths is null) throw new NullReferenceException(nameof(configuration.MixedYearRelativePaths));
|
if (configuration.MixedYearRelativePaths is null) throw new NullReferenceException(nameof(configuration.MixedYearRelativePaths));
|
||||||
|
if (configuration.ModelDirectory is null) throw new NullReferenceException(nameof(configuration.ModelDirectory));
|
||||||
|
if (configuration.ModelName is null) throw new NullReferenceException(nameof(configuration.ModelName));
|
||||||
if (configuration.NumberOfJitters is null) throw new NullReferenceException(nameof(configuration.NumberOfJitters));
|
if (configuration.NumberOfJitters is null) throw new NullReferenceException(nameof(configuration.NumberOfJitters));
|
||||||
if (configuration.NumberOfTimesToUpsample is null) throw new NullReferenceException(nameof(configuration.NumberOfTimesToUpsample));
|
if (configuration.NumberOfTimesToUpsample is null) throw new NullReferenceException(nameof(configuration.NumberOfTimesToUpsample));
|
||||||
|
if (configuration.OutputExtension is null) throw new NullReferenceException(nameof(configuration.OutputExtension));
|
||||||
if (configuration.OutputQuality is null) throw new NullReferenceException(nameof(configuration.OutputQuality));
|
if (configuration.OutputQuality is null) throw new NullReferenceException(nameof(configuration.OutputQuality));
|
||||||
if (configuration.OutputResolutions is null) throw new NullReferenceException(nameof(configuration.OutputResolutions));
|
if (configuration.OutputResolutions is null) throw new NullReferenceException(nameof(configuration.OutputResolutions));
|
||||||
if (configuration.OverrideForFaceImages is null) throw new NullReferenceException(nameof(configuration.OverrideForFaceImages));
|
if (configuration.OverrideForFaceImages is null) throw new NullReferenceException(nameof(configuration.OverrideForFaceImages));
|
||||||
if (configuration.OverrideForFaceLandmarkImages is null) throw new NullReferenceException(nameof(configuration.OverrideForFaceLandmarkImages));
|
if (configuration.OverrideForFaceLandmarkImages is null) throw new NullReferenceException(nameof(configuration.OverrideForFaceLandmarkImages));
|
||||||
if (configuration.OverrideForResizeImages is null) throw new NullReferenceException(nameof(configuration.OverrideForResizeImages));
|
if (configuration.OverrideForResizeImages is null) throw new NullReferenceException(nameof(configuration.OverrideForResizeImages));
|
||||||
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||||
|
if (configuration.PredictorModelName is null) throw new NullReferenceException(nameof(configuration.PredictorModelName));
|
||||||
if (configuration.PropertiesChangedForDistance is null) throw new NullReferenceException(nameof(configuration.PropertiesChangedForDistance));
|
if (configuration.PropertiesChangedForDistance is null) throw new NullReferenceException(nameof(configuration.PropertiesChangedForDistance));
|
||||||
if (configuration.PropertiesChangedForFaces is null) throw new NullReferenceException(nameof(configuration.PropertiesChangedForFaces));
|
if (configuration.PropertiesChangedForFaces is null) throw new NullReferenceException(nameof(configuration.PropertiesChangedForFaces));
|
||||||
if (configuration.PropertiesChangedForIndex is null) throw new NullReferenceException(nameof(configuration.PropertiesChangedForIndex));
|
if (configuration.PropertiesChangedForIndex is null) throw new NullReferenceException(nameof(configuration.PropertiesChangedForIndex));
|
||||||
@ -141,14 +160,19 @@ public class Configuration
|
|||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
Configuration? configuration;
|
Configuration? configuration;
|
||||||
if (isEnvironment is null)
|
if (isEnvironment is null)
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationRoot.Get<Configuration>();
|
configuration = configurationRoot.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||||
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
||||||
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationSection.Get<Configuration>();
|
configuration = configurationSection.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
}
|
}
|
||||||
|
PreVerify(configurationRoot, configuration);
|
||||||
result = Get(configuration);
|
result = Get(configuration);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ public class Program
|
|||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
private static void Main()
|
||||||
{
|
{
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new DragDropSearch());
|
Application.Run(new DragDropSearch());
|
||||||
|
@ -17,6 +17,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -36,7 +53,10 @@ public class AppSettings
|
|||||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ public class Program
|
|||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
private static void Main()
|
||||||
{
|
{
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new DragDropSetPropertyItem());
|
Application.Run(new DragDropSetPropertyItem());
|
||||||
|
@ -23,6 +23,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -46,7 +63,10 @@ public class AppSettings
|
|||||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -42,6 +59,7 @@ public class AppSettings
|
|||||||
#pragma warning disable IL3050, IL2026
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
#pragma warning restore IL3050, IL2026
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ public class Configuration
|
|||||||
public bool? ForceMetadataLastWriteTimeToCreationTime { get; set; }
|
public bool? ForceMetadataLastWriteTimeToCreationTime { get; set; }
|
||||||
public bool? ForceResizeLastWriteTimeToCreationTime { get; set; }
|
public bool? ForceResizeLastWriteTimeToCreationTime { get; set; }
|
||||||
public string? GenealogicalDataCommunicationFile { get; set; }
|
public string? GenealogicalDataCommunicationFile { get; set; }
|
||||||
|
public string? ImmichAssetsFile { get; set; }
|
||||||
public string[]? IgnoreExtensions { get; set; }
|
public string[]? IgnoreExtensions { get; set; }
|
||||||
public string[]? JLinks { get; set; }
|
public string[]? JLinks { get; set; }
|
||||||
public string? LinkedAlpha { get; set; }
|
public string? LinkedAlpha { get; set; }
|
||||||
@ -93,6 +94,7 @@ public class Configuration
|
|||||||
public int? SortingMaximumPerKey { get; set; }
|
public int? SortingMaximumPerKey { get; set; }
|
||||||
public int? SortingMinimumToUseSigma { get; set; }
|
public int? SortingMinimumToUseSigma { get; set; }
|
||||||
public bool? TestDistanceResults { get; set; }
|
public bool? TestDistanceResults { get; set; }
|
||||||
|
public bool? UseExtraPersonKeyCheck { get; set; }
|
||||||
public int? UseFilterTries { get; set; }
|
public int? UseFilterTries { get; set; }
|
||||||
public string[]? ValidKeyWordsToIgnoreInRandom { get; set; }
|
public string[]? ValidKeyWordsToIgnoreInRandom { get; set; }
|
||||||
public string[]? ValidResolutions { get; set; }
|
public string[]? ValidResolutions { get; set; }
|
||||||
@ -103,7 +105,22 @@ public class Configuration
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning restore csharp_preserve_single_line_statements
|
private static void PreVerify(IConfigurationRoot configurationRoot, Configuration? configuration)
|
||||||
|
{
|
||||||
|
if (configuration?.CheckDFaceAndUpWriteDates 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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.Configuration Get(Configuration? configuration, Property.Models.Configuration propertyConfiguration)
|
private static Models.Configuration Get(Configuration? configuration, Property.Models.Configuration propertyConfiguration)
|
||||||
{
|
{
|
||||||
@ -130,6 +147,7 @@ public class Configuration
|
|||||||
if (configuration?.ForceMetadataLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForceMetadataLastWriteTimeToCreationTime));
|
if (configuration?.ForceMetadataLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForceMetadataLastWriteTimeToCreationTime));
|
||||||
if (configuration?.ForceResizeLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForceResizeLastWriteTimeToCreationTime));
|
if (configuration?.ForceResizeLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForceResizeLastWriteTimeToCreationTime));
|
||||||
if (configuration?.GenealogicalDataCommunicationFile is null) throw new NullReferenceException(nameof(configuration.GenealogicalDataCommunicationFile));
|
if (configuration?.GenealogicalDataCommunicationFile is null) throw new NullReferenceException(nameof(configuration.GenealogicalDataCommunicationFile));
|
||||||
|
if (configuration?.ImmichAssetsFile is null) throw new NullReferenceException(nameof(configuration.ImmichAssetsFile));
|
||||||
// if (configuration?.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
// if (configuration?.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
// if (configuration?.JLinks is null) throw new NullReferenceException(nameof(configuration.JLinks));
|
// if (configuration?.JLinks is null) throw new NullReferenceException(nameof(configuration.JLinks));
|
||||||
// if (configuration?.LinkedAlpha is null) throw new NullReferenceException(nameof(configuration.LinkedAlpha));
|
// if (configuration?.LinkedAlpha is null) throw new NullReferenceException(nameof(configuration.LinkedAlpha));
|
||||||
@ -196,6 +214,7 @@ public class Configuration
|
|||||||
if (configuration?.SortingMaximumPerKey is null) throw new NullReferenceException(nameof(configuration.SortingMaximumPerKey));
|
if (configuration?.SortingMaximumPerKey is null) throw new NullReferenceException(nameof(configuration.SortingMaximumPerKey));
|
||||||
if (configuration?.SortingMinimumToUseSigma is null) throw new NullReferenceException(nameof(configuration.SortingMinimumToUseSigma));
|
if (configuration?.SortingMinimumToUseSigma is null) throw new NullReferenceException(nameof(configuration.SortingMinimumToUseSigma));
|
||||||
if (configuration?.TestDistanceResults is null) throw new NullReferenceException(nameof(configuration.TestDistanceResults));
|
if (configuration?.TestDistanceResults is null) throw new NullReferenceException(nameof(configuration.TestDistanceResults));
|
||||||
|
if (configuration?.UseExtraPersonKeyCheck is null) throw new NullReferenceException(nameof(configuration.UseExtraPersonKeyCheck));
|
||||||
if (configuration?.UseFilterTries is null) throw new NullReferenceException(nameof(configuration.UseFilterTries));
|
if (configuration?.UseFilterTries is null) throw new NullReferenceException(nameof(configuration.UseFilterTries));
|
||||||
// if (configuration?.ValidKeyWordsToIgnoreInRandom is null) throw new NullReferenceException(nameof(configuration.ValidKeyWordsToIgnoreInRandom));
|
// if (configuration?.ValidKeyWordsToIgnoreInRandom is null) throw new NullReferenceException(nameof(configuration.ValidKeyWordsToIgnoreInRandom));
|
||||||
// if (configuration?.ValidResolutions is null) throw new NullReferenceException(nameof(configuration.ValidResolutions));
|
// if (configuration?.ValidResolutions is null) throw new NullReferenceException(nameof(configuration.ValidResolutions));
|
||||||
@ -220,6 +239,7 @@ public class Configuration
|
|||||||
configuration.ForceMetadataLastWriteTimeToCreationTime.Value,
|
configuration.ForceMetadataLastWriteTimeToCreationTime.Value,
|
||||||
configuration.ForceResizeLastWriteTimeToCreationTime.Value,
|
configuration.ForceResizeLastWriteTimeToCreationTime.Value,
|
||||||
configuration.GenealogicalDataCommunicationFile,
|
configuration.GenealogicalDataCommunicationFile,
|
||||||
|
configuration.ImmichAssetsFile,
|
||||||
configuration.IgnoreExtensions ?? [],
|
configuration.IgnoreExtensions ?? [],
|
||||||
configuration.JLinks ?? [],
|
configuration.JLinks ?? [],
|
||||||
configuration.LinkedAlpha,
|
configuration.LinkedAlpha,
|
||||||
@ -286,6 +306,7 @@ public class Configuration
|
|||||||
configuration.SortingMaximumPerKey.Value,
|
configuration.SortingMaximumPerKey.Value,
|
||||||
configuration.SortingMinimumToUseSigma.Value,
|
configuration.SortingMinimumToUseSigma.Value,
|
||||||
configuration.TestDistanceResults.Value,
|
configuration.TestDistanceResults.Value,
|
||||||
|
configuration.UseExtraPersonKeyCheck.Value,
|
||||||
configuration.UseFilterTries.Value,
|
configuration.UseFilterTries.Value,
|
||||||
configuration.ValidKeyWordsToIgnoreInRandom ?? [],
|
configuration.ValidKeyWordsToIgnoreInRandom ?? [],
|
||||||
configuration.ValidResolutions ?? []);
|
configuration.ValidResolutions ?? []);
|
||||||
@ -297,14 +318,19 @@ public class Configuration
|
|||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
Configuration? configuration;
|
Configuration? configuration;
|
||||||
if (isEnvironment is null)
|
if (isEnvironment is null)
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationRoot.Get<Configuration>();
|
configuration = configurationRoot.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||||
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
||||||
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationSection.Get<Configuration>();
|
configuration = configurationSection.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
}
|
}
|
||||||
|
PreVerify(configurationRoot, configuration);
|
||||||
result = Get(configuration, propertyConfiguration);
|
result = Get(configuration, propertyConfiguration);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ public record Configuration(Property.Models.Configuration PropertyConfiguration,
|
|||||||
bool ForceMetadataLastWriteTimeToCreationTime,
|
bool ForceMetadataLastWriteTimeToCreationTime,
|
||||||
bool ForceResizeLastWriteTimeToCreationTime,
|
bool ForceResizeLastWriteTimeToCreationTime,
|
||||||
string GenealogicalDataCommunicationFile,
|
string GenealogicalDataCommunicationFile,
|
||||||
|
string ImmichAssetsFile,
|
||||||
string[] IgnoreExtensions,
|
string[] IgnoreExtensions,
|
||||||
string[] JLinks,
|
string[] JLinks,
|
||||||
string? LinkedAlpha,
|
string? LinkedAlpha,
|
||||||
@ -87,6 +88,7 @@ public record Configuration(Property.Models.Configuration PropertyConfiguration,
|
|||||||
int SortingMaximumPerKey,
|
int SortingMaximumPerKey,
|
||||||
int SortingMinimumToUseSigma,
|
int SortingMinimumToUseSigma,
|
||||||
bool TestDistanceResults,
|
bool TestDistanceResults,
|
||||||
|
bool UseExtraPersonKeyCheck,
|
||||||
int UseFilterTries,
|
int UseFilterTries,
|
||||||
string[] ValidKeyWordsToIgnoreInRandom,
|
string[] ValidKeyWordsToIgnoreInRandom,
|
||||||
string[] ValidResolutions);
|
string[] ValidResolutions);
|
@ -16,6 +16,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -36,7 +53,10 @@ public class AppSettings
|
|||||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,9 @@ namespace View_by_Distance.Metadata.Query.Models.Binder;
|
|||||||
public class Configuration
|
public class Configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
#nullable disable
|
public string[]? IgnoreExtensions { get; set; }
|
||||||
|
public Property.Models.Configuration? PropertyConfiguration { get; set; }
|
||||||
public string[] IgnoreExtensions { get; set; }
|
public string? PersonBirthdayFormat { get; set; }
|
||||||
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
|
||||||
public string PersonBirthdayFormat { get; set; }
|
|
||||||
|
|
||||||
#nullable restore
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
@ -21,12 +17,30 @@ public class Configuration
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, Configuration? configuration)
|
||||||
|
{
|
||||||
|
if (configuration?.IgnoreExtensions 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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||||
|
if (configuration.PropertyConfiguration is null) throw new NullReferenceException(nameof(configuration.PropertyConfiguration));
|
||||||
result = new(
|
result = new(
|
||||||
configuration.IgnoreExtensions,
|
configuration.IgnoreExtensions,
|
||||||
configuration.PersonBirthdayFormat,
|
configuration.PersonBirthdayFormat,
|
||||||
@ -39,14 +53,19 @@ public class Configuration
|
|||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
Configuration? configuration;
|
Configuration? configuration;
|
||||||
if (isEnvironment is null)
|
if (isEnvironment is null)
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationRoot.Get<Configuration>();
|
configuration = configurationRoot.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||||
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
||||||
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationSection.Get<Configuration>();
|
configuration = configurationSection.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
}
|
}
|
||||||
|
PreVerify(configurationRoot, configuration);
|
||||||
result = Get(configuration);
|
result = Get(configuration);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -40,7 +57,10 @@ public class AppSettings
|
|||||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,9 @@ namespace View_by_Distance.Mirror.Length.Models.Binder;
|
|||||||
public class Configuration
|
public class Configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
#nullable disable
|
public string[]? IgnoreExtensions { get; set; }
|
||||||
|
public Property.Models.Configuration? PropertyConfiguration { get; set; }
|
||||||
public string[] IgnoreExtensions { get; set; }
|
public string? PersonBirthdayFormat { get; set; }
|
||||||
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
|
||||||
public string PersonBirthdayFormat { get; set; }
|
|
||||||
|
|
||||||
#nullable restore
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
@ -21,12 +17,30 @@ public class Configuration
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, Configuration? configuration)
|
||||||
|
{
|
||||||
|
if (configuration?.IgnoreExtensions 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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||||
|
if (configuration.PropertyConfiguration is null) throw new NullReferenceException(nameof(configuration.PropertyConfiguration));
|
||||||
result = new(
|
result = new(
|
||||||
configuration.IgnoreExtensions,
|
configuration.IgnoreExtensions,
|
||||||
configuration.PersonBirthdayFormat,
|
configuration.PersonBirthdayFormat,
|
||||||
@ -39,14 +53,19 @@ public class Configuration
|
|||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
Configuration? configuration;
|
Configuration? configuration;
|
||||||
if (isEnvironment is null)
|
if (isEnvironment is null)
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationRoot.Get<Configuration>();
|
configuration = configurationRoot.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||||
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
||||||
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationSection.Get<Configuration>();
|
configuration = configurationSection.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
}
|
}
|
||||||
|
PreVerify(configurationRoot, configuration);
|
||||||
result = Get(configuration);
|
result = Get(configuration);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -44,7 +61,10 @@ public class AppSettings
|
|||||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,9 @@ namespace View_by_Distance.Move.By.Id.Models.Binder;
|
|||||||
public class Configuration
|
public class Configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
#nullable disable
|
public string[]? IgnoreExtensions { get; set; }
|
||||||
|
public Property.Models.Configuration? PropertyConfiguration { get; set; }
|
||||||
public string[] IgnoreExtensions { get; set; }
|
public string? PersonBirthdayFormat { get; set; }
|
||||||
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
|
||||||
public string PersonBirthdayFormat { get; set; }
|
|
||||||
|
|
||||||
#nullable restore
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
@ -21,12 +17,30 @@ public class Configuration
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, Configuration? configuration)
|
||||||
|
{
|
||||||
|
if (configuration?.IgnoreExtensions 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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||||
|
if (configuration.PropertyConfiguration is null) throw new NullReferenceException(nameof(configuration.PropertyConfiguration));
|
||||||
result = new(
|
result = new(
|
||||||
configuration.IgnoreExtensions,
|
configuration.IgnoreExtensions,
|
||||||
configuration.PersonBirthdayFormat,
|
configuration.PersonBirthdayFormat,
|
||||||
@ -39,14 +53,19 @@ public class Configuration
|
|||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
Configuration? configuration;
|
Configuration? configuration;
|
||||||
if (isEnvironment is null)
|
if (isEnvironment is null)
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationRoot.Get<Configuration>();
|
configuration = configurationRoot.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||||
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
||||||
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationSection.Get<Configuration>();
|
configuration = configurationSection.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
}
|
}
|
||||||
|
PreVerify(configurationRoot, configuration);
|
||||||
result = Get(configuration);
|
result = Get(configuration);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -36,7 +53,10 @@ public class AppSettings
|
|||||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,9 @@ namespace View_by_Distance.Offset.Date.Time.Original.Models.Binder;
|
|||||||
public class Configuration
|
public class Configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
#nullable disable
|
public string[]? IgnoreExtensions { get; set; }
|
||||||
|
public Property.Models.Configuration? PropertyConfiguration { get; set; }
|
||||||
public string[] IgnoreExtensions { get; set; }
|
public string? PersonBirthdayFormat { get; set; }
|
||||||
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
|
||||||
public string PersonBirthdayFormat { get; set; }
|
|
||||||
|
|
||||||
#nullable restore
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
@ -21,12 +17,30 @@ public class Configuration
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, Configuration? configuration)
|
||||||
|
{
|
||||||
|
if (configuration?.IgnoreExtensions 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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||||
|
if (configuration.PropertyConfiguration is null) throw new NullReferenceException(nameof(configuration.PropertyConfiguration));
|
||||||
result = new(
|
result = new(
|
||||||
configuration.IgnoreExtensions,
|
configuration.IgnoreExtensions,
|
||||||
configuration.PersonBirthdayFormat,
|
configuration.PersonBirthdayFormat,
|
||||||
@ -39,14 +53,19 @@ public class Configuration
|
|||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
Configuration? configuration;
|
Configuration? configuration;
|
||||||
if (isEnvironment is null)
|
if (isEnvironment is null)
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationRoot.Get<Configuration>();
|
configuration = configurationRoot.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||||
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
||||||
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationSection.Get<Configuration>();
|
configuration = configurationSection.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
}
|
}
|
||||||
|
PreVerify(configurationRoot, configuration);
|
||||||
result = Get(configuration);
|
result = Get(configuration);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -36,7 +53,10 @@ public class AppSettings
|
|||||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,8 @@ namespace View_by_Distance.PrepareForOld.Models.Binder;
|
|||||||
public class Configuration
|
public class Configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
#nullable disable
|
public Property.Models.Configuration? PropertyConfiguration { get; set; }
|
||||||
|
public string[]? Spelling { get; set; }
|
||||||
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
|
||||||
public string[] Spelling { get; set; }
|
|
||||||
|
|
||||||
#nullable restore
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
|
@ -39,6 +39,23 @@ public class Configuration
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, Configuration? configuration)
|
||||||
|
{
|
||||||
|
if (configuration?.DateGroup 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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
@ -101,15 +118,19 @@ public class Configuration
|
|||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
Configuration? configuration;
|
Configuration? configuration;
|
||||||
if (isEnvironment is null)
|
if (isEnvironment is null)
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationRoot.Get<Configuration>();
|
configuration = configurationRoot.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||||
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
||||||
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationSection.Get<Configuration>();
|
configuration = configurationSection.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
}
|
}
|
||||||
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
PreVerify(configurationRoot, configuration);
|
||||||
result = Get(configuration);
|
result = Get(configuration);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -49,6 +66,7 @@ public class AppSettings
|
|||||||
#pragma warning disable IL3050, IL2026
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
#pragma warning restore IL3050, IL2026
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,23 @@ public class Configuration
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, Configuration? configuration)
|
||||||
|
{
|
||||||
|
if (configuration?.ForceMetadataLastWriteTimeToCreationTime 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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.Configuration Get(Configuration? configuration, Property.Models.Configuration propertyConfiguration)
|
private static Models.Configuration Get(Configuration? configuration, Property.Models.Configuration propertyConfiguration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
@ -39,14 +56,19 @@ public class Configuration
|
|||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
Configuration? configuration;
|
Configuration? configuration;
|
||||||
if (isEnvironment is null)
|
if (isEnvironment is null)
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationRoot.Get<Configuration>();
|
configuration = configurationRoot.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||||
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
||||||
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationSection.Get<Configuration>();
|
configuration = configurationSection.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
}
|
}
|
||||||
|
PreVerify(configurationRoot, configuration);
|
||||||
result = Get(configuration, propertyConfiguration);
|
result = Get(configuration, propertyConfiguration);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -38,7 +55,10 @@ public class AppSettings
|
|||||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,9 @@ namespace View_by_Distance.Set.Created.Date.Models.Binder;
|
|||||||
public class Configuration
|
public class Configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
#nullable disable
|
public string[]? IgnoreExtensions { get; set; }
|
||||||
|
public Property.Models.Configuration? PropertyConfiguration { get; set; }
|
||||||
public string[] IgnoreExtensions { get; set; }
|
public string? PersonBirthdayFormat { get; set; }
|
||||||
public Property.Models.Configuration PropertyConfiguration { get; set; }
|
|
||||||
public string PersonBirthdayFormat { get; set; }
|
|
||||||
|
|
||||||
#nullable restore
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
@ -21,12 +17,30 @@ public class Configuration
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, Configuration? configuration)
|
||||||
|
{
|
||||||
|
if (configuration?.IgnoreExtensions 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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.Configuration Get(Configuration? configuration)
|
private static Models.Configuration Get(Configuration? configuration)
|
||||||
{
|
{
|
||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
if (configuration.PersonBirthdayFormat is null) throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||||
|
if (configuration.PropertyConfiguration is null) throw new NullReferenceException(nameof(configuration.PropertyConfiguration));
|
||||||
result = new(
|
result = new(
|
||||||
configuration.IgnoreExtensions,
|
configuration.IgnoreExtensions,
|
||||||
configuration.PersonBirthdayFormat,
|
configuration.PersonBirthdayFormat,
|
||||||
@ -39,14 +53,19 @@ public class Configuration
|
|||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
Configuration? configuration;
|
Configuration? configuration;
|
||||||
if (isEnvironment is null)
|
if (isEnvironment is null)
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationRoot.Get<Configuration>();
|
configuration = configurationRoot.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||||
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
||||||
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationSection.Get<Configuration>();
|
configuration = configurationSection.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
}
|
}
|
||||||
|
PreVerify(configurationRoot, configuration);
|
||||||
result = Get(configuration);
|
result = Get(configuration);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -37,6 +54,7 @@ public class AppSettings
|
|||||||
#pragma warning disable IL3050, IL2026
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
#pragma warning restore IL3050, IL2026
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ public class Configuration
|
|||||||
public bool? ForceMetadataLastWriteTimeToCreationTime { get; set; }
|
public bool? ForceMetadataLastWriteTimeToCreationTime { get; set; }
|
||||||
public bool? ForceResizeLastWriteTimeToCreationTime { get; set; }
|
public bool? ForceResizeLastWriteTimeToCreationTime { get; set; }
|
||||||
public string? GenealogicalDataCommunicationFile { get; set; }
|
public string? GenealogicalDataCommunicationFile { get; set; }
|
||||||
|
public string? ImmichAssetsFile { get; set; }
|
||||||
public string[]? IgnoreExtensions { get; set; }
|
public string[]? IgnoreExtensions { get; set; }
|
||||||
public string[]? JLinks { get; set; }
|
public string[]? JLinks { get; set; }
|
||||||
public string[]? LoadOrCreateThenSaveDistanceResultsForOutputResolutions { get; set; }
|
public string[]? LoadOrCreateThenSaveDistanceResultsForOutputResolutions { get; set; }
|
||||||
@ -98,7 +99,22 @@ public class Configuration
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning restore csharp_preserve_single_line_statements
|
private static void PreVerify(IConfigurationRoot configurationRoot, Configuration? configuration)
|
||||||
|
{
|
||||||
|
if (configuration?.CheckDFaceAndUpWriteDates 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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.Configuration Get(Configuration? configuration, Property.Models.Configuration propertyConfiguration)
|
private static Models.Configuration Get(Configuration? configuration, Property.Models.Configuration propertyConfiguration)
|
||||||
{
|
{
|
||||||
@ -125,6 +141,7 @@ public class Configuration
|
|||||||
if (configuration?.ForceMetadataLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForceMetadataLastWriteTimeToCreationTime));
|
if (configuration?.ForceMetadataLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForceMetadataLastWriteTimeToCreationTime));
|
||||||
if (configuration?.ForceResizeLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForceResizeLastWriteTimeToCreationTime));
|
if (configuration?.ForceResizeLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForceResizeLastWriteTimeToCreationTime));
|
||||||
if (configuration?.GenealogicalDataCommunicationFile is null) throw new NullReferenceException(nameof(configuration.GenealogicalDataCommunicationFile));
|
if (configuration?.GenealogicalDataCommunicationFile is null) throw new NullReferenceException(nameof(configuration.GenealogicalDataCommunicationFile));
|
||||||
|
if (configuration?.ImmichAssetsFile is null) throw new NullReferenceException(nameof(configuration.ImmichAssetsFile));
|
||||||
// if (configuration?.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
// if (configuration?.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
// if (configuration?.JLinks is null) throw new NullReferenceException(nameof(configuration.JLinks));
|
// if (configuration?.JLinks is null) throw new NullReferenceException(nameof(configuration.JLinks));
|
||||||
// if (configuration?.LoadOrCreateThenSaveDistanceResultsForOutputResolutions is null) throw new NullReferenceException(nameof(configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions));
|
// if (configuration?.LoadOrCreateThenSaveDistanceResultsForOutputResolutions is null) throw new NullReferenceException(nameof(configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions));
|
||||||
@ -208,6 +225,7 @@ public class Configuration
|
|||||||
configuration.ForceMetadataLastWriteTimeToCreationTime.Value,
|
configuration.ForceMetadataLastWriteTimeToCreationTime.Value,
|
||||||
configuration.ForceResizeLastWriteTimeToCreationTime.Value,
|
configuration.ForceResizeLastWriteTimeToCreationTime.Value,
|
||||||
configuration.GenealogicalDataCommunicationFile,
|
configuration.GenealogicalDataCommunicationFile,
|
||||||
|
configuration.ImmichAssetsFile,
|
||||||
configuration.IgnoreExtensions ?? [],
|
configuration.IgnoreExtensions ?? [],
|
||||||
configuration.JLinks ?? [],
|
configuration.JLinks ?? [],
|
||||||
configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions ?? [],
|
configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions ?? [],
|
||||||
@ -278,14 +296,19 @@ public class Configuration
|
|||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
Configuration? configuration;
|
Configuration? configuration;
|
||||||
if (isEnvironment is null)
|
if (isEnvironment is null)
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationRoot.Get<Configuration>();
|
configuration = configurationRoot.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||||
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
||||||
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationSection.Get<Configuration>();
|
configuration = configurationSection.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
}
|
}
|
||||||
|
PreVerify(configurationRoot, configuration);
|
||||||
result = Get(configuration, propertyConfiguration);
|
result = Get(configuration, propertyConfiguration);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ public record Configuration(Property.Models.Configuration PropertyConfiguration,
|
|||||||
bool ForceMetadataLastWriteTimeToCreationTime,
|
bool ForceMetadataLastWriteTimeToCreationTime,
|
||||||
bool ForceResizeLastWriteTimeToCreationTime,
|
bool ForceResizeLastWriteTimeToCreationTime,
|
||||||
string GenealogicalDataCommunicationFile,
|
string GenealogicalDataCommunicationFile,
|
||||||
|
string ImmichAssetsFile,
|
||||||
string[] IgnoreExtensions,
|
string[] IgnoreExtensions,
|
||||||
string[] JLinks,
|
string[] JLinks,
|
||||||
string[] LoadOrCreateThenSaveDistanceResultsForOutputResolutions,
|
string[] LoadOrCreateThenSaveDistanceResultsForOutputResolutions,
|
||||||
|
@ -17,6 +17,23 @@ public class AppSettings
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
|
||||||
|
{
|
||||||
|
if (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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||||
{
|
{
|
||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
@ -37,6 +54,7 @@ public class AppSettings
|
|||||||
#pragma warning disable IL3050, IL2026
|
#pragma warning disable IL3050, IL2026
|
||||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||||
#pragma warning restore IL3050, IL2026
|
#pragma warning restore IL3050, IL2026
|
||||||
|
PreVerify(configurationRoot, appSettings);
|
||||||
result = Get(appSettings);
|
result = Get(appSettings);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,22 @@ public class Configuration
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning restore csharp_preserve_single_line_statements
|
private static void PreVerify(IConfigurationRoot configurationRoot, Configuration? configuration)
|
||||||
|
{
|
||||||
|
if (configuration?.CheckDFaceAndUpWriteDates 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())}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Models.Configuration Get(Configuration? configuration, Property.Models.Configuration propertyConfiguration)
|
private static Models.Configuration Get(Configuration? configuration, Property.Models.Configuration propertyConfiguration)
|
||||||
{
|
{
|
||||||
@ -278,14 +293,19 @@ public class Configuration
|
|||||||
Models.Configuration result;
|
Models.Configuration result;
|
||||||
Configuration? configuration;
|
Configuration? configuration;
|
||||||
if (isEnvironment is null)
|
if (isEnvironment is null)
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationRoot.Get<Configuration>();
|
configuration = configurationRoot.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||||
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
string section = string.Concat(environmentName, ":", nameof(Configuration));
|
||||||
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||||
|
#pragma warning disable IL3050, IL2026
|
||||||
configuration = configurationSection.Get<Configuration>();
|
configuration = configurationSection.Get<Configuration>();
|
||||||
|
#pragma warning restore IL3050, IL2026
|
||||||
}
|
}
|
||||||
|
PreVerify(configurationRoot, configuration);
|
||||||
result = Get(configuration, propertyConfiguration);
|
result = Get(configuration, propertyConfiguration);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user