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 ...
随机推荐
- Linux学习笔记(16)Linux前后台进程切换(fg/bg/jobs/ctrl+z)
关键词:Linux前后台进程切换,linux进程切换 fg.bg.jobs.&.ctrl + z都是跟系统任务有关的,虽然现在基本上不怎么需要用到这些命令,但学会了也是很实用的一.& ...
- 创建Maven Web项目时很慢解决办法
点击加号,Name输入archetypeCatalog,Value输入internal archetypeCatalog表示插件使用的archetype元数据,不加这个参数时默认为remote,loc ...
- sublime集成MinGW,打造C/C++开发环境
MinGW是是将GCC编译器和GNU Binutils移植到Win32平台下的产物,包括一系列头文件(Win32API).库和可执行文件.MinGW是从Cygwin(1.3.3版)基础上发展而来.GC ...
- 使用php过滤emoji表情
/** * 过滤字符串中表情 * @param $str string 昵称 * @return string */ public function filterEmoji($str) { $str ...
- 使用 vscode将本地项目上传到github、从github克隆项目以及删除github上的某个文件夹
安装Git后,可以看到windows环境下有两个命令输入窗口Git CMD 和Git Bash Git GUI是可视化图形界面 Git中的Bash是基于CMD的,在CMD的基础上增添一些新的命令与功能 ...
- C语言实现远程代码注入
#include <windows.h> #include <iostream> #define STRLEN 20 typedef struct _DATA { DWORD ...
- java -cp 执行jar包里的某个类
当我们需要测试某个功能时,需要在linux环境下执行某个类的main方法来测试 可以使用java -cp xxx.jar com.MyClass来执行某个类 java -cp test.jar:lib ...
- git bash中不能显示中文
git bash中不能显示中文 问题描述:当使用git log查看提交日志时,中文字符不能正常显示问题 1.首先把git的配置改一下 git config --global core.quotepat ...
- (转)Cvte提前批
1. 加密解密了解么?几种算法,讲一下你了解的(链接) 算法选择:对称加密AES,非对称加密: ECC,消息摘要: MD5,数字签名:DSA 常见加密算法 1.DES(Data Encryption ...
- springboot拦截中自动注入的组件为null问题解决方法
一.写SpringUtil类来获取Springh管理的类实例,判断是否注入成功,如果没有注入成功重新获取注入 package com.util; import org.springframework. ...