您的位置:首页 > 编程语言

利用消息机制实现.NET AOP(面向方面编程)--通过RealProxy实现

2006-07-26 18:49 411 查看
通过RealProxy是最简单的方法,缺点是不能同时加入多个代理,否则会抛异常。

实现步骤:

1、实现RealProxy的继承类

2、实现应用上述实现的RealProxy类的ProxyAttribute

3、把上述实现的Attribute应用到ContextBoundObject实例上

//MyProxy代码
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Proxies;
using System.Runtime.Remoting.Activation;
using System.Runtime.Remoting.Services;
using System.Diagnostics;

namespace DotNetAOP.UsingRealProxy
//MyProxyAttribute
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Remoting.Proxies;

namespace DotNetAOP.UsingRealProxy
//MyCBO代码
using System;
using System.Collections.Generic;
using System.Text;

namespace DotNetAOP.UsingRealProxy

//测试代码
using System;
using System.Collections.Generic;
using System.Text;

namespace DotNetAOP

我曾试图实现多个RealProxy嵌套代理对象,不过最后以失败告终,不过后面的两个实现都是可以应用多个截获的。


下载:嵌套RealProxy框架的简单实现 这个框架以失败告终,原因是一个对象不能有多个代理,奇怪的是RemotingProxy又可以,还有待研究。
需要上面单个RealProxy实现的请留下Email。

查看其它框架实现请转到此页


利用消息机制实现.NET AOP(面向方面编程)--通过RealProxy实现
利用消息机制实现.NET AOP(面向方面编程)--利用RealProxy和消息接收器实现多截获
利用消息机制实现.NET AOP(面向方面编程)--利用ServerContextSink实现多截获
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: