2023-05-30 19:25:55 +02:00
|
|
|
|
using Bit.Core.Enums;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
2022-12-02 20:24:30 +01:00
|
|
|
|
|
|
|
|
|
namespace Bit.Infrastructure.IntegrationTest;
|
|
|
|
|
|
2023-05-30 19:25:55 +02:00
|
|
|
|
public class Database
|
|
|
|
|
{
|
|
|
|
|
public SupportedDatabaseProviders Type { get; set; }
|
|
|
|
|
public string ConnectionString { get; set; } = default!;
|
|
|
|
|
public bool UseEf { get; set; }
|
|
|
|
|
public bool Enabled { get; set; } = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal class TypedConfig
|
|
|
|
|
{
|
|
|
|
|
public Database[] Databases { get; set; } = default!;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-02 20:24:30 +01:00
|
|
|
|
public static class ConfigurationExtensions
|
|
|
|
|
{
|
2023-05-30 19:25:55 +02:00
|
|
|
|
public static Database[] GetDatabases(this IConfiguration config)
|
2022-12-02 20:24:30 +01:00
|
|
|
|
{
|
2023-05-30 19:25:55 +02:00
|
|
|
|
var typedConfig = config.Get<TypedConfig>();
|
|
|
|
|
if (typedConfig.Databases == null)
|
2022-12-02 20:24:30 +01:00
|
|
|
|
{
|
2023-05-30 19:25:55 +02:00
|
|
|
|
return Array.Empty<Database>();
|
2022-12-02 20:24:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-30 19:25:55 +02:00
|
|
|
|
return typedConfig.Databases.Where(d => d.Enabled).ToArray();
|
2022-12-02 20:24:30 +01:00
|
|
|
|
}
|
|
|
|
|
}
|