From: Deyan P. <de...@ho...> - 2004-10-28 07:45:08
|
Hi, Obviously my reply from yesterday with an attachment was blocked. So I send another one, this time I have placed my test project on the web: http://www20.brinkster.com/deyanp/dynproxy/DynamicProxyAvalonTest.zip 10x, hammett, and sorry to bother you with this. Br, Deyan ----- Original Message ----- From: "hammett" <ha...@uo...> To: <asp...@li...> Sent: Wednesday, October 27, 2004 8:15 PM Subject: Re: [Aspectsharp-users] IInvocation.Proxy and IInvocation.InvocationTarget > Hello Deyan, > > > I have been playing with the new IInvocation, and I noticed that both > > properties IInvocation.Proxy and IInvocation.InvocationTarget are the > > same. > > What's there meaning, btw? > > The target means: when I invoke proceed, which object will receive the > execution; and the proxy is the proxy itself. When proxying a class, both > values will be the same. When intercepting interfaces (using > ProxyGenerator.CreateProxy) then the values will be different. > > > What is bothering me is that there is no way to substitute the real object > > in the PreProcess method of my Interceptor, which is a part of the object > > lazy-loading process... > > Well, this is easy to fix. We can make the InvocationTarget writable, but > then the Proceed in the SameClassInvocation must be changed to something > like: > > public override object Proceed(params object[] args) > { > object value = null; > if (TargetInvocation == Proxy) > { > value = call.Call( args ); > } > else > { > value = Method.Invoke( InvocationTarget, args ); > } > return value; > } > > Because there is no wasy to use the delegate to invoke the method somewhere > else. I could even generate two different delegates: one to invoke the > base() and one to invoke anotherobject() but in this case I must know the > Type of the anotherobject during the object generation, something like: > > private void callback_1(int x) > { > base.DoSomething(x); > } > > private void otherobjectcallback(int x) > { > // This is generated by > // gen.Emit( OpCodes.callvirt, typeof(target).GetMethod("DoSomething", new > type[] { typeof(int) } ); > target.DoSomething(x); > } > > > > I see that NHibernate also has this problem, as it > > retrieves the real object from the db and delegates (using runtime > > reflection) the calls to it. I would like to execute the methods on the > > real > > object without runtime reflection, which means that either I can substitte > > the real object (perhaps this is the IInvocation.InvocationTarget which > > has > > only a getter) - this I think is not possible, or populate the properties > > of > > the proxy from the db at runtime, and then take advantage of the Dynamic > > Proxy new calling infrastructure. > > Can you expose your code somewhere so we can see exactly the problem? > It will be easier to picture the solution... > > -- > Cheers, > hammett > http://www.digitalcraftsmen.com.br/~hammett > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Sybase ASE Linux Express Edition - download now for FREE > LinuxWorld Reader's Choice Award Winner for best database on Linux. > http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click > _______________________________________________ > Aspectsharp-users mailing list > Asp...@li... > https://lists.sourceforge.net/lists/listinfo/aspectsharp-users > |