Autofac的AOP面向切面编程研究
发布日期:2021-05-09 09:07:56 浏览次数:20 分类:博客文章

本文共 3424 字,大约阅读时间需要 11 分钟。

 

���������AOP���

��������������� ��������������������������������������� =������������������������������ ���Aspect������������������AOP��������������������������������������������� =��� ������������

������������������

���Aspect��� ��� ������������ ��������������������������������������� ��������� ���Aspect��� ������2��������������������������������������������������������� ������������Aspect���

��������������������������� Transaction ������

���������������������������������������Transaction���������������������TransactionScope���

���������������������������������������������������������ORM������

���������������������

��������������� ������ ���������������������db ������������������ ��������� person ���insert���db��� ������������������������ ������school ���person ������������db ������������������

������������������������������������������������������������������������������������������������������������������������������������

������������������������������������������������ ���������������������������������������������������������AOP������������������������������

���������������������������������������

���������������

������������ ��������������������������������������������������� EnableTransactionScope ������ ��������������������������������������������������� ���������������������������

��������������������������� ������������������������

  1. ���������������������������������������������������������������������������(���������������������������������)
  2. ���������������DI���������������������������������������DI���������������������������������������
  3. ���������������������������������������������������������������������������������������

������������������������ Just Do It

1. ������ ������DI������ ������ ���

���2������������autofac���������������������������������������2������ ���������������������������������1���������2

���3���������������������������

����������������~~

������������������������������������������autofac������������������������������������ ������������������������������������

2. ������������ ������������AOP������������������

������������������������������

������������������������

3. ���������������������TransactionScope������

 

������������class������������PointcutAttribute ������������������ ������������������������������ ������������ new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)

��������������������������������������������������������������� [EnableTransactionScope] ������������

������

���������������������������������������������������������AOP���������������������������������������������(������������������������Arround���)

���������������������

  • ������Componet������������������������autofac���������
  • ������Aspect���������������������������autofac���������������������
  • ���������������������������������(���������������������������PointCut������)������������������������
������������ ������������ ������
������������ ������AspectBeforeAttribute ���������������������������������������������������������-������������������
������������ ������AspectAfterAttribute ���������������������������������(���������������)���������������-������������������������
������������ ������AspectAroundAttribute ������������������������������������������������������������-���������������-������������������������
PointCut������ ������PointcutAttribute ������������������������������������������������������������TransactionScope������������������������

���������������

上一篇:微信jssdk的getLocalImgData拿到的base64不完整
下一篇:SpringBoot的注解注入功能移植到.Net平台(开源)

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2025年03月31日 08时24分00秒