This post was updated on April 15, please re-read.. :)
I’ve been working on a PostSharp adapter for Conversation per Business Transaction, in unhaddins.
If you want to read more about the pattern, I recommend you Fabio Maulo’s posts:
- Part I : Conversation-per-Business-Transaction
- Part II : Implementing Conversation per Business Transaction
- Part III (without AOP) : Using Conversation per Business Transacti
- Part IV: Aspect Conversation-per-BusinessTransaction
Currently there are three adapters for CpBT in unhaddins:
- Castle DynamicProxy
- and the brand new for PostSharp
The technology is different (dynamic subclassing vs il weaving) and so the implementation and usage, but I’ve tried hard to keep the API consistent with the previous versions.
The attribute that you need to use is
[ PsPersistenceConversational ] [PersistenceConversational]. This attribute could be used on top of the class; this is almost exactly than the previous version PersistenceConversational(MethodsIncludeMode = Implicit. This means that all public methods excluding the constructor, are conversational methods, unless a method with [PsPersistenceConversational(Exclude = True)]. The attribute works almost exactly as the original version, key differences:
- If the MethodsIncludeMode is set to Implicit, all public members (methods or properties, virtual or sealed) are included in the conversation.
- In order to exclude a public member when using MethodsIncludeMode = Implicit you must decorate the member with [PersistenceConversation(Exclude = True)], this is the same than the original version.
- In order to include a member (public, protected or privated) you must decorate the member with [PersistenceConversation(…)]
If you want to set explicitly which methods are included in the conversation, you just put the attribute above each conversational method.
This is an example WinForms presenter;
As you can see in the ViewCancelClicked and ViewSaveClicked events handlers, one of the most important advantages of PostSharp is that you can include private members as part of the conversation.
Important note; in order to use this addin you must have PostSharp
1.5 2 installed.
I will write an small application soon, this is all for now! If you have any question you can reach me in the unhaddins google group.