Multicast PostSharp Aspects C#

PostSharp Aspects are really powerful in applying some useful Aspects like Handling Exception. If you don’t know about PostShap Exception handling Check this Post.

One of PostSharp powerful Utilities is Multicast which is simply applying an Aspect to a whole Namespace with a single line of code .. Magic isn’t it 🙂

You can Multicast an Aspect by simply adding the following line to the Solution AssemblyInfo.cs File under Properties.

[assembly: ExceptionAspect(AttributeTargetTypes = "AOP_Project.Code.*")]

ExceptionAspect is the name of the Aspect i want to insert and “AOP_Project.Code.*” is the target namespace where all the classes under it will have that Aspect while building the solution.

That’s it now you can apply Exception Aspect to all your solution with a single line 🙂

Advertisements

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s