Monday, August 28, 2006 4:52 PM
So here I am working on a bit of code, and it has to execute after a transaction. I am trying to follow a POCO (similar to POJO but stands for Plain Old CLR Object) model so I start wondering where in the hell I am going to put this code.
I see that Castle has some cool Transaction stuff that I haven't used yet in the Castle.Services.Transactions and there is a handy class for doing just what I want, ISynchronization. I wonder if I can borrow some stellar ideas from Rhino.Commons and make a generic ISynchronization object that will automatically register itself?
namespace Rhino.Commons
{
using Castle.Services.Transaction;
public class Synchronizer : ISynchronization
{
Proc _before;
Proc _after;
public Synchronizer(Proc before, Proc after)
{
this._after = after;
this._before = before;
Kernel.Resolve<ITransactionManager>().CurrentTransaction.RegisterSynchronization(this);
}
#region ISynchronization Members
public void AfterCompletion()
{
this._after();
}
public void BeforeCompletion()
{
this._before();
}
#endregion
}
}
I recognize that I am still inexperienced in alot of aspects of programming, and unfortunatly I have not spent a lot of time trying to find a similar open source business app that I can study. If anyone has any suggestions I would sure appriciate it.