Merge pull request #21 from Bubuni-Team/feature/ignore-module-loading

Allow skip loading part of modules
This commit is contained in:
Kruzya
2022-12-07 07:31:50 +04:00
committed by GitHub
+13
View File
@@ -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
public Core(IConfiguration configuration)
@@ -111,6 +118,12 @@ namespace Kruzya.TelegramBot.Core
/// <returns><see cref="IEnumerable{T}"/> if success, null otherwise.</returns>
private IEnumerable<Type>? LoadAssembly(string path)
{
var fileName = Path.GetFileNameWithoutExtension(path).ToString();
if (_ignoredAssemblyFilenames.Contains(fileName))
{
return null;
}
Assembly assembly;
try
{