29-自己动手构建RequestDelegate管道
1-使用vsCode新建个项目

2-新建RequestDelegate和Context
public delegate Task RequestDelegate(Context context);
public class Context{
}
3-Proggram.cs类
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace MypipleLine
{
class Program
{
private static List<Func<RequestDelegate,RequestDelegate>> _list =
new List<Func<RequestDelegate, RequestDelegate>>();
static void Main(string[] args)
{
Use((next)=>{
return (context)=>{
Console.WriteLine("");
return next.Invoke(context);
};
});
Use((next)=>{
return (context)=>{
Console.WriteLine("");
return next.Invoke(context);
};
}); RequestDelegate end = context=>{
Console.WriteLine("end");
return Task.CompletedTask;
}; _list.Reverse();
foreach(var middleware in _list)
{
end = middleware.Invoke(end);
} end.Invoke(new Context());
} static void Use(Func<RequestDelegate,RequestDelegate> middleware){
_list.Add(middleware);
} }
}
4-显示结果为

29-自己动手构建RequestDelegate管道的更多相关文章
- 【ASP.NET Core快速入门】(八)Middleware管道介绍、自己动手构建RequestDelegate管道
中间件是汇集到以处理请求和响应的一个应用程序管道的软件. 每个组件: 可以选择是否要将请求传递到管道中的下一个组件. 之前和之后调用管道中的下一个组件,可以执行工作. 使用请求委托来生成请求管道. 请 ...
- 菜鸟入门【ASP.NET Core】8:Middleware管道介绍、自己动手构建RequestDelegate管道
中间件:是汇集到以处理请求和响应的一个应用程序管道的软件. 每个组件: 可以选择是否要将请求传递到管道中的下一个组件. 之前和之后调用管道中的下一个组件,可以执行工作. 使用请求委托来生成请求管道. ...
- 任务29:自己动手构建RequestDelegate管道
cmd创建一个控制台应用程序 dotnet new console --name MyPipeline 用VSCode打开这个项目 新建类RequestDelegate.cs的类文件复制Program ...
- 构建RequestDelegate管道
1. 创建 Context.cs using System; using System.Threading.Tasks; namespace MyPipeline { public class Con ...
- .net core 2.0学习记录(四):Middleware使用以及模拟构建Middleware(RequestDelegate)管道
.net Core中没有继续沿用以前asp.net中的管道事件,而是开发了一个新的管道(Middleware): public class MiddlewareDemo { private reado ...
- 任务28:RequestDelegate管道实现思路
任务28:RequestDelegate管道实现思路 管道的实现机制 RequestDelegate是管道的核心.ApplicationBuilder就是接收了很多个RequestDelegae把它拼 ...
- Kafka笔记7(构建数据管道)
构建数据管道需要考虑的问题: 及时性 可靠性 高吞吐量和动态吞吐量 数据格式 转换 安全性 故障处理能力 耦合性与灵活性 数据管道的构建分为2个阵营,ETL和ELT ETL:提取- ...
- ASP.NET Core Middleware管道介绍
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.Use(async (context, ne ...
- ASP.NET Core快速入门_学习笔记汇总
第2章 配置管理 任务12:Bind读取配置到C#实例 任务13:在Core Mvc中使用Options 任务14:配置的热更新 任务15:配置框架设计浅析 第3章 依赖注入 任务16:介绍- 任务1 ...
随机推荐
- angular2-搭建环境
npm 模块将被下载安装到[全局目录]中.[全局目录]通过 npm config set prefix "目录路径" 来设置.通过 npm config get prefix 来 ...
- Struts1.x 用户登录模块的实现
页面验证部分: <%@ page language="java" contentType="text/html; charset=UTF-8" pageE ...
- Selenium 元素查找
1.尽量使用ID或者name去定位元素,如果这个元素没有ID或者Name,那么就是用它最近的父节点的ID或者Name去定位. 2.写自动化脚本不是一个人的事情,是一个团队的事情,合作能更好,更轻松得完 ...
- 百万级数据库SQL优化大总结
网上关于SQL优化的教程很多,但是比较杂乱.近日有空整理了一下,写出来跟大家分享一下,其中有错误和不足的地方,还请大家纠正补充. 这篇文章我花费了大量的时间查找资料.修改.排版,希望大家阅读之后,感觉 ...
- Element-ui(el-table、el-pagination)实现表格分页
HTML代码:(重点关注el-table中:data数据的绑定) el-pagination中: layout代表组件布局,子组件名用逗号分隔 属性: total代表总条目数 事件: current- ...
- Verilog三线 - 八线译码器
参阅了一些书籍和网上的写法,在此Mark. 布尔表达式法 module decode3_8_assign (data_in,data_out,enable);//算法实现 :] data_in; in ...
- 测试笔记:本地存储localstorage与sessionstorage
最近测试的投票项目开发说用的是localstorage.查了下是h5的本地存储.还有个sessionstorage,区别在于sessonstorage关闭页面后清空,localstorage保留. 以 ...
- POJ-2481 Cows---树状数组的运用
题目链接: https://vjudge.net/problem/POJ-2481 题目大意: if Si <= Sj and Ej <= Ei and Ei - Si > Ej - ...
- 2月4号学习的一个SSM整合项目,第一课
本文引自:https://github.com/Sunybyjava/seckill 原作者:sunybyjava@gmail.com seckill 一个整合SSM框架的高并发和商品秒杀项目,学习 ...
- mac home brew install go
mac利器home brew安装Go 首先你得需要安装home brew和ruby环境(因为home brew依赖ruby) 如果没有请自行到链接安装 准备好之后就开始安装go了 brew updat ...