The core infrastructure backend (API, database, Docker, etc).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

34 lines
1.2 KiB

using Bit.Core.Settings;
using Microsoft.Extensions.Configuration;
namespace Bit.DbSeederUtility;
public static class GlobalSettingsFactory
{
private static GlobalSettings? _globalSettings;
public static GlobalSettings GlobalSettings
{
get { return _globalSettings ??= LoadGlobalSettings(); }
}
private static GlobalSettings LoadGlobalSettings()
{
Console.WriteLine("Loading global settings...");
var configBuilder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", optional: true, reloadOnChange: true)
.AddUserSecrets("bitwarden-Api") // Load user secrets from the API project
.AddEnvironmentVariables();
var configuration = configBuilder.Build();
var globalSettingsSection = configuration.GetSection("globalSettings");
var settings = new GlobalSettings();
globalSettingsSection.Bind(settings);
return settings;
}
}