mirror of
https://github.com/anjoy8/Blog.Core.git
synced 2025-02-08 02:39:26 +08:00
Table of Contents
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
1、系列文章
https://www.cnblogs.com/laozhang-is-phi/category/1290896.html
2、哪些AOP
A、内存缓存AOP
B、Redis缓存AOP
C、日志AOP
这三个AOP对应的文件地址:
├─Blog.Core
├──AOP
│ ├─BlogCacheAOP.cs
│ ├─BlogLogAOP.cs
│ ├─BlogRedisCacheAOP.cs
D、SqlSugar 生产Sql语句AOP(在仓储层 DbContext.cs 上下文中 _db.Aop.OnLogExecuting)
3、配置AOP是否启用
在 appsettings.json 文件中配置:
"RedisCaching": {
"Enabled": false,
"ConnectionString": "127.0.0.1:6319"
},
"MemoryCachingAOP": {
"Enabled": true
},
"LogAOP": {
"Enabled": true
},
4、Startup.cs 中注入服务
builder.RegisterType<BlogCacheAOP>();//可以直接替换其他拦截器
builder.RegisterType<BlogRedisCacheAOP>();//可以直接替换其他拦截器
builder.RegisterType<BlogLogAOP>();//这样可以注入第二个
// AOP 开关,如果想要打开指定的功能,只需要在 appsettigns.json 对应对应 true 就行。
var cacheType = new List<Type>();
if (Appsettings.app(new string[] { "AppSettings", "RedisCaching", "Enabled" }).ObjToBool())
{
cacheType.Add(typeof(BlogRedisCacheAOP));
}
if (Appsettings.app(new string[] { "AppSettings", "MemoryCachingAOP", "Enabled" }).ObjToBool())
{
cacheType.Add(typeof(BlogCacheAOP));
}
if (Appsettings.app(new string[] { "AppSettings", "LogAOP", "Enabled" }).ObjToBool())
{
cacheType.Add(typeof(BlogLogAOP));
}
builder.RegisterAssemblyTypes(assemblysServices)
.AsImplementedInterfaces()
.InstancePerLifetimeScope()
.EnableInterfaceInterceptors()//引用Autofac.Extras.DynamicProxy;
// 如果你想注入两个,就这么写 InterceptedBy(typeof(BlogCacheAOP), typeof(BlogLogAOP));
// 如果想使用Redis缓存,请必须开启 redis 服务,端口号我的是6319,如果不一样还是无效,否则请使用memory缓存 BlogCacheAOP
.InterceptedBy(cacheType.ToArray());//允许将拦截器服务的列表分配给注册。
入门指南
-
- AOP
- Appsettings
- Async-Await
- Authorization-Ids4
- Authorization-JWT
- AutoMapper
- CORS
- DI-AutoFac
- DI-NetCore
- Filter
- GlobalExceptionsFilter
- HttpContext
- Log4
- MemoryCache
- Middleware
- MiniProfiler
- publish
- Redis
- Repository
- SeedData
- SignalR
- SqlSugar
- SqlSugar-Codefirst&DataSeed
- SqlSugar-SqlAOP
- Swagger
- T4
- Test-xUnit
- Temple-Nuget
前端项目
交流与反馈
- FAQ page is a good place to see whether your question is already asked.
- Ask a question in cnblogs if you need help.
- Submit an issue if you found a bug or have a feature request.
- Open a pull request when you prepared to contribute. Before that, it is encouraged to open an issue to discuss.
更新日志
有疑问,请自行查看博客园文章:https://www.cnblogs.com/laozhang-is-phi/p/9495618.html#autoid-1-0-0
或者加 QQ 群:867095512