Sunday, February 01, 2009

Aspect oriented programming (AOP)
.Net implementation

What is Aspect-oriented Programming?
Manage and separate your own cross cutting concern from your business functionality.

Introduction
I’ve seen many different AOP frameworks implementations in .NET and most of them seems to me too complex to understand.
In this article i will introduce how to make AOP done in your solution.


MessageCallAspect and how does it work?
Wrap any module with TargetInspectorProxy, this will be your module context.
It creates a transparent proxy which will be your reference along the process.
The transparent proxy gets called for each method/ propery invocation of the target.
The transparent proxy serializes the call stack and passes that on to the TargetInspectorProxy.
The TargetInspectorProxy calls the message sink chain, the last one on the chain calls the actual target.
This sink chain is the actual interception on the method call processing. (also known as Aspect)

These aspects can be defined in two ways:
1. TargetInspectorProxy by his constructor.
2. Implement MessageSinkAttribute's and define them on method/propery/class

Project name: MessageCallAspect (beta of the beta but stable)
Project hosting: http://code.google.com/p/messagecallaspect/



useful links:

http://msdn.microsoft.com/en-us/magazine/cc164165.aspx


Friday, April 04, 2008

Saturday, December 15, 2007

Global Event Distributor

Introduction
This articles discusses how to add event handlers by defining custom attributes on the event definitions and their handler methods.

Background
By using EventDistirbutor, you don't need to have references between the event and its handler method class.

Short example
Publish your event:

[PublishEvent("OnOver")]
public event EventHandler OnOver;

Subscribe to the event:

[SubscriberEvent("OnOver")]
public void OnOver(object sender, EventArgs e)
{
Console.WriteLine("OnOver From Class A");
}//method acccesor should be public

Project name: EventDistributor
Download