惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 【当耐特】
Help Net Security
Help Net Security
P
Proofpoint News Feed
J
Java Code Geeks
爱范儿
爱范儿
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Full Disclosure
Google DeepMind News
Google DeepMind News
H
Help Net Security
G
Google Developers Blog
Jina AI
Jina AI
Vercel News
Vercel News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
Lohrmann on Cybersecurity
S
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
Security Archives - TechRepublic
Security Archives - TechRepublic
阮一峰的网络日志
阮一峰的网络日志
N
News and Events Feed by Topic
GbyAI
GbyAI
B
Blog
O
OpenAI News
博客园_首页
Cisco Talos Blog
Cisco Talos Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hacker News: Ask HN
Hacker News: Ask HN
TaoSecurity Blog
TaoSecurity Blog
腾讯CDC
MongoDB | Blog
MongoDB | Blog
M
MIT News - Artificial intelligence
C
Cybersecurity and Infrastructure Security Agency CISA
Cyberwarzone
Cyberwarzone
Webroot Blog
Webroot Blog
Simon Willison's Weblog
Simon Willison's Weblog
Y
Y Combinator Blog
C
Cisco Blogs
A
Arctic Wolf
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Exploit Database - CXSecurity.com
Security Latest
Security Latest
AI
AI
W
WeLiveSecurity
aimingoo的专栏
aimingoo的专栏
The Register - Security
The Register - Security
Project Zero
Project Zero
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
Netflix TechBlog - Medium
Blog — PlanetScale
Blog — PlanetScale

博客园 - rex

C#编译javascript - JQuery模板 将C#编译为javascript TouchPad App - Advanced Calculator TouchPad App - Unit converter webOS App - Simple Unit Convert 在javascript库中整合Sizzle(Sizzle引擎的使用) source code upload to google code RexStudio2.0RC c# 2.0 Factory的实现 Emit生成Property C#2.0 Singleton 的实现 .NET 分布式事务处理 Castle IoC castle 五子棋:) *.ashx:HttpHandler的另一种用法 自己制作的ORMap框架终于完成的差不多了。 VStudio 2003 remote debug Application Container
AOP static crosscutting 的一个实现
rex · 2005-07-07 · via 博客园 - rex

        AOP的动态拦截已经有太多的文章了,但关于静态横切的实现却比较少,因此,我想提供一个实现思路来达到抛砖引玉的目的。
        实现的思想主要如下:
        将需要weave-in的源代码写入一个文件(例如 log.aspect),然后拦截new操作符(这可以参考其他人的文章,用ProxyAttribute加从MarshalByRefObject继承)或者构造的时候采用factory模式,返回要生成的对象的继承类,这里我采用的是生成一个临时的源文件,并采用CodeDom中的动态编译。基本上临时文件代码如下:

public class aop_Target : Target
{
//此处插入要weave-in的代码(从*.aspect中读取),例如
//public void Log(string msg)
//{
//  
//}
}

这样的实现比较简单,但效率一定是比较差的,相信采用Emit会有很大的提高。

最后,Weave-in的方法的调用只能采用反射加Invoke,这大概是一个比较大的弱点,但在完全采用C#编译器的前提下,大概也只能做到这样了。