开发者

How could I use pointcut in C# using AOP

I have developed a Application using pointcut(AOP Around) in java.i.e.

pointcut ps(String s,int iTemp1,int iTemp2) :
    call (void java.awt.Graphics.drawString(String,int,int)) && args(s,iTemp1,iTemp2);

void around(String s,int i1,int i2) : ps(s,i1,i2)
{
  if(flag1)
 {
     try
     {
       //Some code
     }
     catch(Exception ex)
     {
     }
  } 



s=image_applet.foo(s);

if(flag2)
 {
     try
     {
      //code
     }
     catch(Exception ex)
     {
     }
  } 

proceed(s,iTemp1,iTemp2);
}

and I want to develop same pointcut in our methods which is us开发者_Go百科ed in my c# code.If it is possible den please give me some directions.


I've used Spring.NET's AOP implementations with great success - maybe that could work for you?


Checkout the NKalore project @ http://aspectsharpcomp.sourceforge.net/

There are loads of AOP spoofs in .NET including the handicapped Code Contracts. However to my knowledge NKalore is the only one that mirrors AspectJ grammar and patterns. Other frameworks like LinFu, post sharp (starter edition) require you to place attributes and follow a different pattern. There is no AOP grammar support because they lack AOP compilers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜