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

推荐订阅源

美团技术团队
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Check Point Blog
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
IT之家
IT之家
月光博客
月光博客
U
Unit 42
K
Kaspersky official blog
T
Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
云风的 BLOG
云风的 BLOG
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Engineering at Meta
Engineering at Meta
Recorded Future
Recorded Future
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security @ Cisco Blogs
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
Security Archives - TechRepublic
Security Archives - TechRepublic
Webroot Blog
Webroot Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Schneier on Security
S
Secure Thoughts
The Register - Security
The Register - Security
B
Blog RSS Feed
The Last Watchdog
The Last Watchdog
P
Palo Alto Networks Blog
爱范儿
爱范儿
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 热门话题
C
Cisco Blogs
Spread Privacy
Spread Privacy
F
Full Disclosure
博客园 - 聂微东
T
The Blog of Author Tim Ferriss

博客园 - bobmazelin

Microsoft Robotics Developer Studio基础(一):前言 Microsoft Robotics Developer Studio beta4的大bug Microsoft Robotics Developer Studio4 Beta随想 最近动态记录 走入Microsoft Robotics Developer Studio世界 【工作流】工作流结构模式整理 【工作流】PE中的资源模式的实现方式 【讨论】【工作流】由资源模式中的“权限分配”想到资源结构 【PE】流程图对象以及事件驱动机制的介绍 【讨论】WF中的异常(错误)处理 【讨论】基于WF的流程结构 建立基于WF工作流模式库的设想 2008:再战Business Process Management System(BPMs) bobmazelin的流程管理系统介绍和概念性设计(三) bobmazelin的流程管理系统介绍和概念性设计(二) bobmazelin的流程管理系统介绍和概念性设计(一) AspectNet功能介绍(二) 在(开发)流程系统之前 在Sequence模式中思考流程资源(数据)问题
AspectNet功能介绍(一)
bobmazelin · 2007-06-29 · via 博客园 - bobmazelin

AspectNet是一个基于.Net Framework的方面编制器,它同时能实现静态编织和动态编织,是bobmazelin个人的研究性项目,现仍然处于开发阶段,有关AOP概念的介绍请参考:www.aspectJ.org以及IBM的专题.

这是AspectNet功能介绍的第一篇,我主要介绍AspectNet在静态编织方面的基本结构.

AspectNet在很大程度上参考了aspectJ,它通过MSIL代码来实现静态编织,由此AspectNet不需要源代码,同时它也可以混合编织C#和VB.Net(理论上VC++.Net也可以)产生的动态链接库.

AspectNet由Aspect组成,每个Aspect都可以声明若干个pointcut,storage以及advice.

1. pointcut的概念和aspectJ基本一致,它捕获需要被织入的代码点;

2. storage是ApsectNet特有的概念,它和pointcut类似,捕获需要织入到pointcut的代码;

3. advice的概念和aspectJ基本一致,但它不需要写任何C#或其他代码,它连接了pointcut和storage,使他们形成了多对多的关系映射.

下面给一个简单的例子来说明这3个概念:

namespace Bob.Mazelin
{
    aspect Demo
    {
        pointcut AddDemo1():call(public void Mazelin.AspectNet.TestProject.TestClass.Demo1());

        before():AddDemo1():PrintBefore();

        after():AddDemo1():PrintAfter();


        storage PrintBefore():call(public void Mazelin.AspectNet.TestProject.PrintClass.PrintBefore());
        storage PrintAfter():call(public void Mazelin.AspectNet.TestProject.PrintClass.PrintAfter());   
    }
}

其中AddDemo1是pointcut的名字,它捕获了Demo1方法,该方法没有返回值,也没有参数,其被全称为Mazelin.AspectNet.TestProject.TestClass类声明.call关键字表明了捕获点为调用该方法的程序点;

PrintBefore和PrintAfter是两个storage类型,它们分别捕获了PrintBefore和PrintAfter方法,其解释意义和pointcut类似;

before和after是advice,它连接了AddDemo1和PrintBefore,PrintAfter,使PrintBefore和PrintAfter分别在AddDemo1调用前和后被调用.

当需要织入的DLL和aspect文件一起运行后,会产生新的织入代码后的DLL.这样的织入方式基本不影响代码的性能,和手工编写代码类似,和动态编织的方式相比性能好,但缺乏灵活性.

今天就先到这里,下次我会介绍AspectNet中call和execution pointcut的使用,还请对AOP由兴趣的朋友多提宝贵意见.

附:很对不起大家,现阶段ApsectNet还不提供下载.