Allow skip loading part of modules

This commit is contained in:
Kruzya
2022-12-05 01:28:02 +04:00
parent a97fac85e4
commit c161cb929b
+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
{