From ad5576958f6e11095c520171f8e3562cf5ca9cdc Mon Sep 17 00:00:00 2001 From: Sergey Karmanov Date: Wed, 15 Oct 2025 00:03:31 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SfeduSchedule/Controllers/ProxyController.cs | 1 + .../Controllers/ScheduleController.cs | 6 +-- SfeduSchedule/PluginLoader.cs | 38 +++++++++---------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/SfeduSchedule/Controllers/ProxyController.cs b/SfeduSchedule/Controllers/ProxyController.cs index bc9e931..7e6eb05 100644 --- a/SfeduSchedule/Controllers/ProxyController.cs +++ b/SfeduSchedule/Controllers/ProxyController.cs @@ -20,6 +20,7 @@ public class ProxyController(ModeusService modeusService, ILoggerВозвращает расписание /// Слишком много запросов [HttpPost] + [Route("events/search")] public async Task Post([FromBody] ModeusScheduleRequest request) { string? schedule; diff --git a/SfeduSchedule/Controllers/ScheduleController.cs b/SfeduSchedule/Controllers/ScheduleController.cs index 605ac4e..2e2958b 100644 --- a/SfeduSchedule/Controllers/ScheduleController.cs +++ b/SfeduSchedule/Controllers/ScheduleController.cs @@ -9,12 +9,12 @@ using SfeduSchedule.Services; namespace SfeduSchedule.Controllers; [ApiController] -[Route("api/[controller]")] +[Route("api/schedule")] [EnableRateLimiting("throttle")] public class ScheduleController(ModeusService modeusService, ILogger logger) : ControllerBase { /// - /// Получить расписание по пользовательскому запросу. + /// [УСТАРЕЛО] Получить расписание по пользовательскому запросу. /// /// Объект запроса, содержащий параметры фильтрации расписания. /// Список событий расписания. @@ -41,7 +41,7 @@ public class ScheduleController(ModeusService modeusService, ILogger - /// Поиск аудиторий по пользовательскому запросу. + /// [УСТАРЕЛО] Поиск аудиторий по пользовательскому запросу. /// /// Объект запроса, содержащий параметры фильтрации аудиторий. /// Список аудиторий. diff --git a/SfeduSchedule/PluginLoader.cs b/SfeduSchedule/PluginLoader.cs index 17c5822..1a28244 100644 --- a/SfeduSchedule/PluginLoader.cs +++ b/SfeduSchedule/PluginLoader.cs @@ -18,20 +18,26 @@ public static class PluginLoader foreach (var file in Directory.EnumerateFiles(pluginsDir, "*.plugin.dll", SearchOption.AllDirectories)) { - var path = Path.GetFullPath(file); - var alc = new PluginLoadContext(path); - var asm = alc.LoadFromAssemblyPath(path); + try + { + var path = Path.GetFullPath(file); + var alc = new PluginLoadContext(path); + var asm = alc.LoadFromAssemblyPath(path); - // Ищем реализацию IPlugin - var pluginType = asm - .GetTypes() - .FirstOrDefault(t => typeof(IPlugin).IsAssignableFrom(t) && !t.IsAbstract && !t.IsInterface); + var pluginType = asm + .GetTypes() + .FirstOrDefault(t => typeof(IPlugin).IsAssignableFrom(t) && !t.IsAbstract && !t.IsInterface); - if (pluginType is null) - continue; + if (pluginType is null) + continue; - var instance = (IPlugin)Activator.CreateInstance(pluginType)!; - result.Add(new LoadedPlugin(instance, asm, alc)); + var instance = (IPlugin)Activator.CreateInstance(pluginType)!; + result.Add(new LoadedPlugin(instance, asm, alc)); + } + catch (Exception ex) + { + Console.WriteLine($"Ошибка загрузки плагина {file}: {ex.Message}"); + } } return result; @@ -39,15 +45,9 @@ public static class PluginLoader } // Отдельный контекст загрузки для изоляции зависимостей плагина -public sealed class PluginLoadContext : AssemblyLoadContext +public sealed class PluginLoadContext(string pluginMainAssemblyPath) : AssemblyLoadContext(isCollectible: true) { - private readonly AssemblyDependencyResolver _resolver; - - public PluginLoadContext(string pluginMainAssemblyPath) - : base(isCollectible: true) - { - _resolver = new AssemblyDependencyResolver(pluginMainAssemblyPath); - } + private readonly AssemblyDependencyResolver _resolver = new(pluginMainAssemblyPath); // Разрешаем управляемые зависимости плагина из его папки. // Возвращаем null, чтобы отдать решение в Default ALC для общих сборок (например, SfeduSchedule.Abstractions).