Plugins: Adding an enabled property

This commit is contained in:
Zoe Roux
2021-08-13 12:01:07 +02:00
parent 2e0c96b228
commit b67e0a629e
6 changed files with 36 additions and 16 deletions
+12 -2
View File
@@ -11,16 +11,26 @@ namespace Kyoo
/// <summary>
/// Get a connection string from the Configuration's section "Database"
/// </summary>
/// <param name="config">The IConfiguration instance to load.</param>
/// <param name="config">The IConfiguration instance to use.</param>
/// <param name="database">The database's name.</param>
/// <returns>A parsed connection string</returns>
public static string GetDatabaseConnection(this IConfiguration config, string database)
{
DbConnectionStringBuilder builder = new();
IConfigurationSection section = config.GetSection("Database").GetSection(database);
IConfigurationSection section = config.GetSection("database:configurations").GetSection(database);
foreach (IConfigurationSection child in section.GetChildren())
builder[child.Key] = child.Value;
return builder.ConnectionString;
}
/// <summary>
/// Get the name of the selected database.
/// </summary>
/// <param name="config">The IConfiguration instance to use.</param>
/// <returns>The name of the selected database.</returns>
public static string GetSelectedDatabase(this IConfiguration config)
{
return config.GetValue<string>("database:enabled");
}
}
}