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.
31 lines
793 B
31 lines
793 B
using Bit.Core.Enums; |
|
using Microsoft.Extensions.Configuration; |
|
|
|
namespace Bit.Infrastructure.IntegrationTest; |
|
|
|
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!; |
|
} |
|
|
|
public static class ConfigurationExtensions |
|
{ |
|
public static Database[] GetDatabases(this IConfiguration config) |
|
{ |
|
var typedConfig = config.Get<TypedConfig>(); |
|
if (typedConfig.Databases == null) |
|
{ |
|
return Array.Empty<Database>(); |
|
} |
|
|
|
return typedConfig.Databases.Where(d => d.Enabled).ToArray(); |
|
} |
|
}
|
|
|