From: hammett <ha...@uo...> - 2004-10-28 14:06:50
|
Hello Deyan Very interesting piece of code. So, you return a place holder with lazy load. Is it something that the user can turn on and off? About the code, I've implemented the writable InvocationTarget and changed your code interceptor to: public class MyInterceptor : IInterceptor { private LoadObjectDelegate _loadObjectDelegate; private int _id; private bool isLoaded; private object newtarget; public MyInterceptor(LoadObjectDelegate loadObjectDelegate, int id) { _loadObjectDelegate = loadObjectDelegate; _id = id; } public object Intercept( IInvocation invocation, params object[] args) { if(invocation.Method.Name.Equals("get_ID")) { return _id; } if (!isLoaded) { newtarget = _loadObjectDelegate( _id ); isLoaded = true; } invocation.InvocationTarget = newtarget; return invocation.Proceed(args); } } The results were Loop1000DynamicProxyTest: 125 Loop1000 NoProxy Test: 16 Loop1000DynamicProxyTest: 47 Loop1000 NoProxy Test: 0 (using Environment.TickCount instead of DateTime.Now) From my standpoint this is good. The first one takes more time because the proxy code generation. After that, it will use the cached type. Now, a better test will be to implement a simple but functional Materialize method, to load it from the database and check if the lazy load is really effective. If the proxy overhead is really making the overall process too slow, we can tweak it as you wish :-) I'm commiting the changes to SVN right now. -- Cheers, hammett http://www.digitalcraftsmen.com.br/~hammett ----- Original Message ----- From: "Deyan Petrov" <de...@ho...> To: <asp...@li...> Sent: Thursday, October 28, 2004 12:45 AM Subject: Re: [Aspectsharp-users] IInvocation.Proxy and IInvocation.InvocationTarget |