C# => 写法
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>(); public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
return WebHost.CreateDefaultBuilder(args).UseStartup<Startup>();
}
Action<object> action =
//函数参数
(object obj)
=>
//函数体
{
Console.WriteLine("");
}; public void action <T>(object obj)
{
Console.WriteLine("");
}
public void test()
{
Action<object> action = new Action<object>(action<object>);
action(new object()); //执行
}
//我的自定义委托
public delegate Task Request_Delegate(HttpContext context);
//我的自定义函数
public Task My_Function(HttpContext context)
{
return context.Response.WriteAsync("");
}
/*
写法1
*/
app.Run(
async (context)
=>
{
await context.Response.WriteAsync("Hello World!_001");
}
);
/*
写法 2
*/
test(app); app.Run(
(context) // 类似于匿名函数
=>
{
return context.Response.WriteAsync("Hello World!");
}
#region --定义带参数的委托
//定义一个委托
public delegate TResult My_Func001<in T1, in T2, out TResult>(T1 arg1, T2 arg2);
public delegate string My_Func0011<in T1, in T2, out TResult>(T1 arg1, T2 arg2);
public string my_func001<T1,T2>(int a,int b)
{
MessageBox.Show("");
return "";
}
/*
My_Func001<int, int,string> my_Func001 = my_func001<int, int>;
my_Func001(1,2); My_Func0011<int, int, string> my_Func001 = my_func001<int, int>;
my_Func001(1, 2); */ public delegate void My_Func002<in T1, in T2>(T1 arg1, T2 arg2);
public void my_func002<T1,T2>(T1 a,T2 b){}
/*
My_Func002<int,int> my_Func002 = my_func002<int, int>;
my_Func002(10,11);
*/
#endregion #region --定义无参数的委托
public delegate void My_Func003<in T1, in T2>(); //无参数
public void my_func003()
{
MessageBox.Show("");
}
public void my_func003<T>()
{
var t = typeof(T);
MessageBox.Show("003<T>" + t.Name);
}
public void my_func003<T1, T2>()
{
var t = typeof(T1);
MessageBox.Show("003<T1,T2>" + t.Name);
}
/*
调用
//声明委托
My_Func003<int, int> my_Func003 = my_func003;
My_Func003<int, int> my_Func003_1 = my_func003<String>;
My_Func003<int, int> my_Func003_12 = my_func003<String, String>;
//执行委托
my_Func003();
my_Func003_1();
my_Func003_12();
*/ #endregion
//研究中e......
namespace WebApplication1.lib
{
//定义一个接口
public interface My_IApplicationBuilder
{
My_IApplicationBuilder Use(Func<RequestDelegate, RequestDelegate> middleware);
}
public static class A
{
// public delegate TResult Func<in T, out TResult>(T arg); public static T test<T>(T a)
{
T temp = default(T); return temp;
}
public static My_IApplicationBuilder testc(this My_IApplicationBuilder app, string str)
{ Func<RequestDelegate, RequestDelegate> middleware = test<RequestDelegate>;
//执行这个函数
//return app.Use(middleware); //函数当参数传递过去 //委托赋值方式 2
Func<RequestDelegate, RequestDelegate> middleware1 = delegate (RequestDelegate next)
{ //返回方法001
MethodInfo[] array = new MethodInfo[] { };
MethodInfo methodInfo = array[];
return (RequestDelegate)new object(); }; //匿名方法 return app.Use(middleware1); //函数当参数传递过去
} }
}
gg了
.net core 如何获取 每次请求URL 比如 http://localhost:62830/h http://localhost:62830/a.txt http://localhost:62830/a.jpg http://localhost:62830/a http://localhost:62830/b
服务器如何获取 每次的请求连接?????
//app.Run(My_Function); // 放在 app.UseMvc 之后,将捕获不到控制器页面 捕获所有请求 ////我的自定义函数
//public async Task My_Function( HttpContext context)
//{
// //RequestHandleHelper request = new RequestHandleHelper(context.Request);
// //var t = ; //请求路径 // var path = context.Request.Path.Value;
// var met = context.Request.Method; // //包含的文件扩展名
// if (path=="1")
// {
// //context.Response.Redirect(path);
// //await context.Response.WriteAsync("Hello, World!");
// }
// else if(path== "/123")
// {
// context.Response.Redirect("/Home/Error");
// }
//}
//其他委托
//定义一个接口
public interface My_IApplicationBuilder
{
My_IApplicationBuilder Use(Func<RequestDelegate, RequestDelegate> middleware);
}
public static class A
{
// public delegate TResult Func<in T, out TResult>(T arg); public static T test<T>(T a)
{
T temp = default(T); return temp;
}
public static My_IApplicationBuilder testc(this My_IApplicationBuilder app, string str)
{ Func<RequestDelegate, RequestDelegate> middleware = test<RequestDelegate>;
//执行这个函数
//return app.Use(middleware); //函数当参数传递过去 //委托赋值方式 2
Func<RequestDelegate, RequestDelegate> middleware1 = delegate (RequestDelegate next)
{ //返回方法001
MethodInfo[] array = new MethodInfo[] { };
MethodInfo methodInfo = array[];
return (RequestDelegate)new object(); }; //匿名方法 return app.Use(middleware1); //函数当参数传递过去
} }
C# => 写法的更多相关文章
- obj.style.z-index的正确写法
obj.style.z-index的正确写法 今天发现obj.style.z-index在js里面报错,后来才知道在js里应该把含"-"的字符写成驼峰式,例如obj.style.z ...
- java设计模式之单例模式(几种写法及比较)
概念: Java中单例模式是一种常见的设计模式,单例模式的写法有好几种,这里主要介绍三种:懒汉式单例.饿汉式单例.登记式单例. 单例模式有以下特点: 1.单例类只能有一个实例. 2.单例类必须自己创建 ...
- .NET跨平台之旅:数据库连接字符串写法引发的问题
最近在一个ASP.NET Core站点中遇到一个奇怪问题.当用dotnet run命令启动站点后,开始的一段时间请求执行速度超慢,有时要超过20秒,有时甚至超过1分钟,日志中会记录这样的错误: Sys ...
- 【兼容写法】HttpServerUtility.Execute 在等待异步操作完成时被阻止。关键词:MVC,分部视图,异步
异常处理汇总-后端系列 http://www.cnblogs.com/dunitian/p/4523006.html MVC6之前的版本,对分部视图的异步支持不是很好 问题: 视图里面有分布视图:@{ ...
- 常用原生JS方法总结(兼容性写法)
经常会用到原生JS来写前端...但是原生JS的一些方法在适应各个浏览器的时候写法有的也不怎么一样的... 今天下班有点累... 就来总结一下简单的东西吧…… 备注:一下的方法都是包裹在一个EventU ...
- touchstart,touchmove,touchend事件 写法
jQuery写法: $('#id').on('touchstart',function(e) { var _touch = e.originalEvent.targetTouches[0]; var ...
- 前端导出Excel兼容写法
今天整理出在Web前端导出Excel的写法,写了一个工具类,对各个浏览器进行了兼容. 首先,导出的数据来源可能有两种: 1. 页面的HTML内容(一般是table) 2. 纯数据 PS:不同的数据源, ...
- Express 4 handlebars 不使用layout写法
Express 4 handlebars 不使用layout写法 Express node nodejs handlebars layout 最近刚开始学习使用nodejs. 使用express搭建了 ...
- javascript函数的几种写法集合
1.常规写法 function fnName(){ console.log("常规写法"); } 2.匿名函数,函数保存到变量里 var myfn = function(){ co ...
- 关于java的递归写法,经典的Fibonacci数的问题
经典的Fibonacci数的问题 主要想展示一下迭代与递归,以及尾递归的三种写法,以及他们各自的时间性能. public class Fibonacci { /*迭代*/ public static ...
随机推荐
- 西安邀请赛-E(树链剖分+线段树)
题目链接:https://nanti.jisuanke.com/t/39272 题意:给一棵树,n个结点,树根为1,n-1条边,每个结点有一个权值.进行3种操作: 1 s t:把1和s之间的最短路径上 ...
- java 兔子生仔问题
题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子对数为多少? 程序分析: 兔子的规律为数列1,1,2,3,5,8 ...
- 【0.2】【MySQL】常用监控指标及监控方法(转)
[MySQL]常用监控指标及监控方法 转自:https://www.cnblogs.com/wwcom123/p/10759494.html 对之前生产中使用过的MySQL数据库监控指标做个小结. ...
- Docker 运行的 应用程序无法连接Oracle数据库的解决办法
1. 最近公司使用docker化部署运行 app 发现一个部门的 多数据源取数的功能连接不上 oracle数据库 报错提示为: 2. 公司平台部同事给出两个解决方案: https://blog.cs ...
- Kick Start 2019 Round F Teach Me
题目链接 题目大意 有 $N$ 个人,$S$ 项技能,这些技能用 $1, 2, 3, \dots, S$ 表示 .第 $i$ 个人会 $c_i$ 项技能($ 1 \le c_i \le 5 $).对于 ...
- jinja2介绍
jinja2介绍 jinja2是Flask作者开发的一个模板系统,起初是仿django模板的一个模板引擎,为Flask提供模板支持,由于其灵活,快速和安全等优点被广泛使用. jinja2的优点 jin ...
- 9.用ExecuteSqlCommand执行存储过程
比如你有一个存储过程 IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CreateAutho ...
- Yii2 常用代码集合
Yii2.0 对数据库查询的一些简单的操作 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 ...
- Javascript问题集锦
1.Date.parse()函数兼容性问题: IE Chrome Firefox Date.parse("07-17-2019") 1563292800000 15632928 ...
- Delphi PopupMenu组件