Wouter,
First, it should be noted that using context bound objects is not aspect
oriented programming. It offers method interception (which aspect oriented
programming has), but that's about it. AOP offers much more than just that.
In order to know ^which^ object is being intercepted, you will have to
implement IContributeEnvoySink or IContributeObjectSink. They both take
references to the MarshalByRefObject which is the ContextBoundObject that is
specific to that object. This allows you to set up an instance of your sink
which is tied to just that object (not all objects of the type).
The IContributeObjectSink will contribute a sink which is called in the
server context, while the IContributeEnvoySink will intercept the call in
the client context.
Additionally, you should ask if you truly want to use context bound
objects in this situation. You are going to take a performance hit (much
more than say, placing a method in each property which will set a flag
internally indicating that a change has been made) because of what is needed
to take the values on the stack and construct them into a message.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Wouter de Kort" <Wouter de
Ko**@discussions.microsoft.com> wrote in message
news:1A**********************************@microsof t.com...
I've started looking at Aspect Oriented Programming but I've stumbled at a
problem I can't solve.
I want to add an Aspect that would notify a UnitOfWork that the current
DomainObject has changed so that it can be marked as Dirty.
I've created an Attribute, MessageSink and ContextProperty and everything
is
working.
So when a property is accessed a function in the MessageSink class is
executed and the only thing the DomainObject has to do is add
[SaveChanges]
to the class declaration.
But how can I pass the current DomainObject to my UnitOfWork? The funciton
in the MessageSink doesn't know about the DomainObject where the
attributed
is used and I don't know how to find out on which DomainObject the
property
is accessed.
Thnx for your help!
Wouter de Kort