当前位置:网站首页>ASP. Net core usage record 2
ASP. Net core usage record 2
2022-07-21 05:26:00 【When the human stars shine】
Web site address :
How to be in .NET Core SDK Switch between versions
.net sdk Version switching
Version change command :dotnet new globaljson --sdk-version edition --force
CultureInfo
System.Globalization Classes under assemblies
it
Provides information about specific cultures ( For unmanaged code development , It is called a “ Zone setup ”) Information about . This information includes the name of the culture 、 The writing system 、 Calendar used 、 Sorting order of strings and formatting settings for dates and numbers .
In short , Is to provide some cultural information about some regions .
API and SDK The difference between
api Service interface , It can be called by everyone , But for developers of different languages , They call api The general flow is the same, but you always need to write the requested code . For those who need to call this frequently api For developers of , Of course, you don't want to write the requested code for each call , I hope it can be called more conveniently , that sdk emerge as the times require , It's right api Further encapsulation of the call , For developers who often use it , Just download sdk, You can use the service directly , There is no need to care about internal api Call mode procedure .
A dynamic proxy AOP function
- install NuGet package :Autofac.Extras.DynamicProxy
AOP I'm not going to repeat the concept here , and dotNET Core Built in interceptors (Filter、 middleware ) Is the difference between the Autofac Of AOP For specific business methods, not HTTP request .
- establish UserServiceInterceptor Interception class , Inherited from IInterceptor:
public class UserServiceInterceptor:IInterceptor
{
public virtual void Intercept(IInvocation invocation)
{
Console.WriteLine($"{
DateTime.Now}: Before method execution ");
invocation.Proceed();
Console.WriteLine($"{
DateTime.Now}: After method execution ");
}
}
2、 modify Startup Class ConfigureContainer Method , Conduct AOP Registration of :
public void ConfigureContainer(ContainerBuilder builder)
{
builder.RegisterType<UserServiceInterceptor>();
builder.RegisterType<UserService>().As<IUserService>()
.EnableInterfaceInterceptors()
.InstancePerLifetimeScope();
}
- register UserServiceInterceptor Interceptor
- register UserService Call... When serving EnableInterfaceInterceptors Enable interceptors
3、 modify UserService class , add to AOP Characteristic marks :
[Intercept(typeof(UserServiceInterceptor))]
public class UserService: IUserService
{
//public IDeptService DeptService { get; set; }
public string GetUserName()
{
Console.WriteLine($"{
DateTime.Now}: Method execution ");
return "oec2003";
//return $"oec2003({DeptService.GetDeptName()})";
}
}
4、 The result of the call is as follows :
边栏推荐
猜你喜欢
1.54寸TFT ST7789液晶屏图片如何取模
node-js 异步处理图片,异步处理json文本
The LAAS protocol of defi 2.0 is the key to revitalizing the development of defi track
ACM warm-up exercise 3 in summer vacation 2022
Autojs learning - package name viewer
Go runtime package
First meeting, MySQL
两种常见的Vlan间通信的方式
【HBuilder运行到MuMu模拟器无法安装基座的问题,一直卡在安装基座...】
Qt 多线程实现的两种方式 线程实现
随机推荐
Okaleido or get out of the NFT siege, are you optimistic about it?
go 多路复用
【el-upload实现一个修改头像的功能】
小程序毕设作品之微信运动场地预约小程序毕业设计(7)中期检查报告
C#:WeChat聊天软件实例(WPF+WebSocket+WebApi+EntityFramework)
Go sync package
Nuscenes数据集总结
Create k26 SOM minimum system
ASP.NET CORE 自定义中间件
Link file of Infineon aurix tc3xx Series MCU
实体注解-批量生成10000条测试数据
每日一题·731.我的日程安排表||·数组
物理实验模拟
Program environment and pretreatment
JUC包下的常见类
Redis implements seckill system
Autojs learning - realize transparent status bar
英飞凌 AURIX TC3XX 系列单片机的链接文件
Console C # flying chess small project
接口遇到jsonString应该怎么处理