Philipp Häfelfinger
f29cb9d373
All checks were successful
PiwigoDirectorySync/pipeline/head This commit looks good
20 lines
1007 B
C#
20 lines
1007 B
C#
using Microsoft.Extensions.Configuration;
|
|
|
|
namespace PiwigoDirectorySync;
|
|
|
|
internal static class AppSettings
|
|
{
|
|
public static readonly IReadOnlySet<string> SupportedExtensions = new HashSet<string> { "jpg", "jpeg", "png" };
|
|
|
|
public static IConfigurationRoot Config { get; } = new ConfigurationBuilder().SetBasePath(AppContext.BaseDirectory)
|
|
.AddJsonFile("appsettings.json", true)
|
|
.AddJsonFile(Path.Combine(Environment.CurrentDirectory, "appsettings.json"), true)
|
|
.AddJsonFile("/etc/PiwigoDirectorySync/appsettings.json", true)
|
|
.AddEnvironmentVariables()
|
|
.Build();
|
|
|
|
public static Settings Settings { get; } = Config.GetSection("settings").Get<Settings>() ?? throw new InvalidOperationException("Could not parse settings");
|
|
|
|
public static string ConnectionString =>
|
|
Config.GetConnectionString(Settings.DbProvider) ?? throw new InvalidOperationException($"Could not find connection string for provider {Settings.DbProvider}");
|
|
} |