José F. Romaniello

Las aventuras y desventuras de un codificador.

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:

Currently there are three adapters for CpBT in unhaddins:

  • Spring.AOP
  • 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.

| More

Aprovecho esta entrada para agradecerle a todas las personas que asistieron a mi VAN de Introducción a la Programación Orientada a Aspectos, como así también a mis amigos de AltNet Hispano.

La solución con todos los ejemplos que mostré esta publicada en este enlace.

El slide de la presentación se puede descargar de este enlace o bien verla directamente aquí:

El video va a estar pronto en la wiki de AltNet Hispano.

Como último quería agradecer a los auspiciantes de esta van:

PostSharp - Code to the Point  

| More