一、安装包
<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;
}
}
}