1
0
mirror of synced 2024-11-30 17:04:28 +01:00
GC-local-server-rewrite/MainServer/Controllers/BaseController.cs

15 lines
532 B
C#
Raw Normal View History

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();
}