I am trying to allow developers to extend my code at certain points of execution.
My specific example is a database transaction wrapper. The wrapper takes care of many details that we wanted to abstract away from the developer and is used on several projects.
Each project however has certain things they would like to do automatically during the transaction. I would like to add interception points that each project can setup to run code.
For example, each table in our database has an Entered Date field that is updated every time the record changes. We however want all the dates to be the same for a transaction across however many records are touched (i.e. 4 records table A, 1 record in table B, ...).
My thought is to define interception points "TransactionStarting", "TransactionStarted", "StatementExecuting", "StatementExecuted", ... and pass a context object to each point.
Then the project can define a class "EnteredDateManager" that stores the current date during the "TransactionStarted" point, and updates each object's EnteredDate property during the "StatementExecuting" point.
I would like to set this up in the web/app.config file and allow multiple interception classes to be registered. If more than one class is registered, they should be fired in the order they were registered.
I was thinking of just raising events, but I want order to matter. I also want to be able to share state between the different points. In my example above, the EnteredDate Property is set in the TransactionStarted point and used in the StatementExecuting point.
Is this the Chain of Responsibility pattern? AOP? It seems close to how the ASP.Net pipeline works, but they use events and don't guarantee ordering as far as I know.
Any direction/examples would be great.
Thanks