【发布时间】:2022-08-02 18:44:08
【问题描述】:
假设我在.NET6 的ConfigureServices 类中的MediatR 中有这些行为:
services.AddMediatR(Assembly.GetExecutingAssembly());
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(UnhandledExceptionBehaviour<,>));
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(AuthorizationBehaviour<,>));
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehaviour<,>));
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(PerformanceBehaviour<,>));
并且此行为应该在实现IRequestHandler 的所有具体CommandHandler 之前执行。
那么这些行为的执行顺序是怎样的呢?如何设置行为执行的优先级?