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>
|
/// <summary>
|
||||||
/// Get a connection string from the Configuration's section "Database"
|
/// Get a connection string from the Configuration's section "Database"
|
||||||
/// </summary>
|
/// </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>
|
/// <param name="database">The database's name.</param>
|
||||||
/// <returns>A parsed connection string</returns>
|
/// <returns>A parsed connection string</returns>
|
||||||
public static string GetDatabaseConnection(this IConfiguration config, string database)
|
public static string GetDatabaseConnection(this IConfiguration config, string database)
|
||||||
{
|
{
|
||||||
DbConnectionStringBuilder builder = new();
|
DbConnectionStringBuilder builder = new();
|
||||||
IConfigurationSection section = config.GetSection("Database").GetSection(database);
|
IConfigurationSection section = config.GetSection("database:configurations").GetSection(database);
|
||||||
foreach (IConfigurationSection child in section.GetChildren())
|
foreach (IConfigurationSection child in section.GetChildren())
|
||||||
builder[child.Key] = child.Value;
|
builder[child.Key] = child.Value;
|
||||||
return builder.ConnectionString;
|
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 />
|
/// <inheritdoc />
|
||||||
public string Description => "A database context for postgresql.";
|
public string Description => "A database context for postgresql.";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public bool Enabled => _configuration.GetSelectedDatabase() == "postgres";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The configuration to use. The database connection string is pulled from it.
|
/// The configuration to use. The database connection string is pulled from it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -22,6 +22,9 @@ namespace Kyoo.SqLite
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string Description => "A database context for sqlite.";
|
public string Description => "A database context for sqlite.";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public bool Enabled => _configuration.GetSelectedDatabase() == "sqlite";
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The configuration to use. The database connection string is pulled from it.
|
/// The configuration to use. The database connection string is pulled from it.
|
||||||
|
@ -116,6 +116,7 @@ namespace Kyoo.Controllers
|
|||||||
.Concat(pluginsPaths.SelectMany(LoadPlugin))
|
.Concat(pluginsPaths.SelectMany(LoadPlugin))
|
||||||
.GroupBy(x => x.Name)
|
.GroupBy(x => x.Name)
|
||||||
.Select(x => x.First())
|
.Select(x => x.First())
|
||||||
|
.Where(x => x.Enabled)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!_plugins.Any())
|
if (!_plugins.Any())
|
||||||
|
@ -43,7 +43,7 @@ namespace Kyoo
|
|||||||
typeof(CoreModule),
|
typeof(CoreModule),
|
||||||
typeof(AuthenticationModule),
|
typeof(AuthenticationModule),
|
||||||
typeof(PostgresModule),
|
typeof(PostgresModule),
|
||||||
// typeof(SqLiteModule),
|
typeof(SqLiteModule),
|
||||||
typeof(PluginTvdb),
|
typeof(PluginTvdb),
|
||||||
typeof(PluginTmdb)
|
typeof(PluginTmdb)
|
||||||
);
|
);
|
||||||
|
@ -10,19 +10,22 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"database": {
|
"database": {
|
||||||
"sqlite": {
|
"enabled": "sqlite",
|
||||||
"data Source": "kyoo.db",
|
"configurations": {
|
||||||
"cache": "Shared"
|
"sqlite": {
|
||||||
},
|
"data Source": "kyoo.db",
|
||||||
"postgres": {
|
"cache": "Shared"
|
||||||
"server": "127.0.0.1",
|
},
|
||||||
"port": "5432",
|
"postgres": {
|
||||||
"database": "kyooDB",
|
"server": "127.0.0.1",
|
||||||
"user ID": "kyoo",
|
"port": "5432",
|
||||||
"password": "kyooPassword",
|
"database": "kyooDB",
|
||||||
"pooling": "true",
|
"user ID": "kyoo",
|
||||||
"maxPoolSize": "95",
|
"password": "kyooPassword",
|
||||||
"timeout": "30"
|
"pooling": "true",
|
||||||
|
"maxPoolSize": "95",
|
||||||
|
"timeout": "30"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user