.NET常用组件

  • 类似于Qt的事件槽机制,Spring.NET的IApplicationEventListener。
  • 当一个对象发出某个类型的事件时,监听这个事件的接受者都会收到并开始自己的处理逻辑
  • 使用
    • 启用:在Startup.cs的ConfigureServices(IServiceCollection services)中使用services.AddMediaR(typeof(Startup));
    • 定义事件:定义一个叫XxxRequest的类实现IRequestIRequest接口
    • 触发事件:_mediator.Send(new XxxRequest());
    • 监听事件:定义一个叫XxxRequestHandler的类实现IRequestHandler接口,并实现Handle()函数
原文地址:https://www.cnblogs.com/wyp1988/p/14690078.html