SharpRush中的AOP实现

 

//aspect code:
    [AttributeUsage(AttributeTargets.Class)]
 
public class SecurityAspectAttribute:AOPAttribute
 
{
  
public SecurityAspectAttribute()
  
{
  }


  
public override void PreProcess(System.Runtime.Remoting.Messaging.IMessage msg)
  
{
   System.Windows.Forms.MessageBox.Show(
"pre");
  }


  
public override void PostProcess(System.Runtime.Remoting.Messaging.IMessage msg)
  
{
   System.Windows.Forms.MessageBox.Show(
"post");
  }

 }

 
 
//client code:
 [SecurityAspect]
 
public class Class1:AOPObject
 
{
  
public Class1()
  
{
  }


  
public void test()
  
{
   System.Windows.Forms.MessageBox.Show(
"test");
  }

 }

posted @ 2005-08-16 16:13  Martin XJ  阅读(860)  评论(0编辑  收藏  举报