mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-06-08 07:15:15 -04:00
Plugins: Adding an enabled property
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user