模拟.net core中间件执行顺序
2021-02-04 05:16
标签:adl next generic set names ons static action public 模拟.net core中间件执行顺序 标签:adl next generic set names ons static action public 原文地址:https://www.cnblogs.com/slwangzi/p/13149675.htmlusing System;
using System.Collections.Generic;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
App app = new App();
app.Use(next => {
Console.WriteLine(1);
return act => {
Console.WriteLine("1-before");
//其它逻辑代码...
Console.WriteLine(act.Url);
next.Invoke(act);
//其它逻辑代码...
Console.WriteLine("1-after");
};
});
app.Use(next => {
Console.WriteLine(2);
return act => {
Console.WriteLine("2-before");
//其它逻辑代码...
next.Invoke(act);
//其它逻辑代码...
Console.WriteLine("2-after");
};
});
app.Use(next => {
Console.WriteLine(3);
return act => {
Console.WriteLine("3-before");
//其它逻辑代码...
next.Invoke(act);
//其它逻辑代码...
Console.WriteLine("3-after");
};
});
Action