mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Plugins: Adding an enabled property
This commit is contained in:
parent
2e0c96b228
commit
b67e0a629e
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
@ -23,6 +23,9 @@ namespace Kyoo.Postgresql
|
||||
/// <inheritdoc />
|
||||
public string Description => "A database context for postgresql.";
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Enabled => _configuration.GetSelectedDatabase() == "postgres";
|
||||
|
||||
/// <summary>
|
||||
/// The configuration to use. The database connection string is pulled from it.
|
||||
/// </summary>
|
||||
|
@ -21,6 +21,9 @@ namespace Kyoo.SqLite
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Description => "A database context for sqlite.";
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Enabled => _configuration.GetSelectedDatabase() == "sqlite";
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -116,6 +116,7 @@ namespace Kyoo.Controllers
|
||||
.Concat(pluginsPaths.SelectMany(LoadPlugin))
|
||||
.GroupBy(x => x.Name)
|
||||
.Select(x => x.First())
|
||||
.Where(x => x.Enabled)
|
||||
);
|
||||
|
||||
if (!_plugins.Any())
|
||||
|
@ -43,7 +43,7 @@ namespace Kyoo
|
||||
typeof(CoreModule),
|
||||
typeof(AuthenticationModule),
|
||||
typeof(PostgresModule),
|
||||
// typeof(SqLiteModule),
|
||||
typeof(SqLiteModule),
|
||||
typeof(PluginTvdb),
|
||||
typeof(PluginTmdb)
|
||||
);
|
||||
|
@ -10,19 +10,22 @@
|
||||
},
|
||||
|
||||
"database": {
|
||||
"sqlite": {
|
||||
"data Source": "kyoo.db",
|
||||
"cache": "Shared"
|
||||
},
|
||||
"postgres": {
|
||||
"server": "127.0.0.1",
|
||||
"port": "5432",
|
||||
"database": "kyooDB",
|
||||
"user ID": "kyoo",
|
||||
"password": "kyooPassword",
|
||||
"pooling": "true",
|
||||
"maxPoolSize": "95",
|
||||
"timeout": "30"
|
||||
"enabled": "sqlite",
|
||||
"configurations": {
|
||||
"sqlite": {
|
||||
"data Source": "kyoo.db",
|
||||
"cache": "Shared"
|
||||
},
|
||||
"postgres": {
|
||||
"server": "127.0.0.1",
|
||||
"port": "5432",
|
||||
"database": "kyooDB",
|
||||
"user ID": "kyoo",
|
||||
"password": "kyooPassword",
|
||||
"pooling": "true",
|
||||
"maxPoolSize": "95",
|
||||
"timeout": "30"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user