Рефактор
All checks were successful
Create and publish a Docker image / Publish image (push) Successful in 4m6s
All checks were successful
Create and publish a Docker image / Publish image (push) Successful in 4m6s
This commit is contained in:
@@ -20,6 +20,7 @@ public class ProxyController(ModeusService modeusService, ILogger<ScheduleContro
|
||||
/// <response code="200">Возвращает расписание</response>
|
||||
/// <response code="429">Слишком много запросов</response>
|
||||
[HttpPost]
|
||||
[Route("events/search")]
|
||||
public async Task<IActionResult> Post([FromBody] ModeusScheduleRequest request)
|
||||
{
|
||||
string? schedule;
|
||||
|
||||
@@ -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<ScheduleController> logger) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Получить расписание по пользовательскому запросу.
|
||||
/// [УСТАРЕЛО] Получить расписание по пользовательскому запросу.
|
||||
/// </summary>
|
||||
/// <param name="request">Объект запроса, содержащий параметры фильтрации расписания.</param>
|
||||
/// <returns>Список событий расписания.</returns>
|
||||
@@ -41,7 +41,7 @@ public class ScheduleController(ModeusService modeusService, ILogger<ScheduleCon
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск аудиторий по пользовательскому запросу.
|
||||
/// [УСТАРЕЛО] Поиск аудиторий по пользовательскому запросу.
|
||||
/// </summary>
|
||||
/// <param name="request">Объект запроса, содержащий параметры фильтрации аудиторий.</param>
|
||||
/// <returns>Список аудиторий.</returns>
|
||||
|
||||
@@ -17,12 +17,13 @@ public static class PluginLoader
|
||||
return result;
|
||||
|
||||
foreach (var file in Directory.EnumerateFiles(pluginsDir, "*.plugin.dll", SearchOption.AllDirectories))
|
||||
{
|
||||
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);
|
||||
@@ -33,21 +34,20 @@ public static class PluginLoader
|
||||
var instance = (IPlugin)Activator.CreateInstance(pluginType)!;
|
||||
result.Add(new LoadedPlugin(instance, asm, alc));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Ошибка загрузки плагина {file}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// Отдельный контекст загрузки для изоляции зависимостей плагина
|
||||
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).
|
||||
|
||||
Reference in New Issue
Block a user