mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
Merge pull request #21 from Bubuni-Team/feature/ignore-module-loading
Allow skip loading part of modules
This commit is contained in:
@@ -62,6 +62,13 @@ namespace Kruzya.TelegramBot.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of filenames (without extension) what should be not loaded.
|
||||||
|
/// </summary>
|
||||||
|
private List<string> _ignoredAssemblyFilenames => _configuration
|
||||||
|
.GetSection("IgnoredModuleFilenames").GetChildren()
|
||||||
|
.Select(q => q.Value).ToList();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public Core(IConfiguration configuration)
|
public Core(IConfiguration configuration)
|
||||||
@@ -111,6 +118,12 @@ namespace Kruzya.TelegramBot.Core
|
|||||||
/// <returns><see cref="IEnumerable{T}"/> if success, null otherwise.</returns>
|
/// <returns><see cref="IEnumerable{T}"/> if success, null otherwise.</returns>
|
||||||
private IEnumerable<Type>? LoadAssembly(string path)
|
private IEnumerable<Type>? LoadAssembly(string path)
|
||||||
{
|
{
|
||||||
|
var fileName = Path.GetFileNameWithoutExtension(path).ToString();
|
||||||
|
if (_ignoredAssemblyFilenames.Contains(fileName))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Assembly assembly;
|
Assembly assembly;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user