1
0
mirror of synced 2024-11-27 23:50:49 +01:00
GC-local-server-rewrite/MainServer/Controllers/BaseController.cs

15 lines
532 B
C#

using MediatR;
using Microsoft.AspNetCore.Mvc;
namespace MainServer.Controllers;
public abstract class BaseController<T> : ControllerBase where T : BaseController<T>
{
private ILogger<T>? logger;
private ISender? mediator;
protected ISender Mediator => (mediator ??= HttpContext.RequestServices.GetService<ISender>()) ?? throw new InvalidOperationException();
protected ILogger<T> Logger => (logger ??= HttpContext.RequestServices.GetService<ILogger<T>>()) ?? throw new InvalidOperationException();
}