Postsharp is an easy-to-learn and easy-to-use AOP framework. Before that, I used aspectj and spring. of course, it takes a little time, but I still feel that it is difficult to master. It seems that AOP is a relatively difficult thing. The description in this English paper does not seem so difficult to grasp. For more information, see.
PS uses what we are familiar with without introducing new terms. This is a wise place for PS. Look at a group of concepts on the right of the table, events (which are not quite understood why Meta is used), event processor, aspect = custom attribute, and the only new one is multicasting, it can be understood as a wildcard expression.
The following is a simple example:
Public Class Logattribute: onmethodboundaryaspect
{
Public Override Void Onentry (methodexecutioneventargs eventargs)
{Console. writeline ("Entering the Method{0}.", Eventargs. method );
}
Public Override Void Onexit (methodexecutioneventargs eventargs)
{
Console. writeline ("Leaving the Method{0}.", Eventargs. method );
}
}
class Program
{< br> [log]
static void main ()
{< br> console. writeline ("Hello, world. ");
}< BR >}< P>
// multicasting indicates that MyApp. use log in the businessobjects namespace
[assembly: log (
attributetargettypes =
"MyApp. businessobjects. * ",
attributetargetmembe Rattributes =
multicastattributes. Public)]
the example is concise, clear, and easy to learn.