一、安装包
<PackageReference Include="MediatR" Version="12.1.1" />
二、编写示例
using MediatR;
namespace WebApplication7
{
public class TestCommand : IRequest<bool>
{
}
public class TestCommandHandler : IRequestHandler<TestCommand, bool>
{
public async Task<bool> Handle(TestCommand request, CancellationToken cancellationToken)
{
return true;
}
}
}




















![洛谷题解 | P9690 [GDCPC2023] Programming Contest](https://img-blog.csdnimg.cn/img_convert/dbc83fac8c627c4a06ca028e2d697a47.png)