From c161cb929bc9508ce5cbcd5c609e582f92f333b1 Mon Sep 17 00:00:00 2001 From: Kruzya Date: Mon, 5 Dec 2022 01:28:02 +0400 Subject: [PATCH] Allow skip loading part of modules --- Core/Core.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Core/Core.cs b/Core/Core.cs index d733d09..b7b9a4d 100644 --- a/Core/Core.cs +++ b/Core/Core.cs @@ -62,6 +62,13 @@ namespace Kruzya.TelegramBot.Core } } + /// + /// List of filenames (without extension) what should be not loaded. + /// + private List _ignoredAssemblyFilenames => _configuration + .GetSection("IgnoredModuleFilenames").GetChildren() + .Select(q => q.Value).ToList(); + #endregion public Core(IConfiguration configuration) @@ -111,6 +118,12 @@ namespace Kruzya.TelegramBot.Core /// if success, null otherwise. private IEnumerable? LoadAssembly(string path) { + var fileName = Path.GetFileNameWithoutExtension(path).ToString(); + if (_ignoredAssemblyFilenames.Contains(fileName)) + { + return null; + } + Assembly assembly; try {