PiwigoDirectorySync/PiwigoDirectorySync/AppSettings.cs
Philipp Häfelfinger f29cb9d373
All checks were successful
PiwigoDirectorySync/pipeline/head This commit looks good
removes secrets as they are not required for this project
2023-09-13 23:30:03 +02:00

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}");
}