2023-08-29 23:54:00 +02:00
using Microsoft.Extensions.Configuration ;
namespace PiwigoDirectorySync ;
2023-09-02 23:44:10 +02:00
internal static class AppSettings
2023-08-29 23:54:00 +02:00
{
2023-08-30 22:47:40 +02:00
public static readonly IReadOnlySet < string > SupportedExtensions = new HashSet < string > { "jpg" , "jpeg" , "png" } ;
2023-08-29 23:54:00 +02:00
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" ) ;
2023-08-30 22:47:40 +02:00
public static string ConnectionString = >
Config . GetConnectionString ( Settings . DbProvider ) ? ? throw new InvalidOperationException ( $"Could not find connection string for provider {Settings.DbProvider}" ) ;
2023-08-29 23:54:00 +02:00
}