1010using System . Diagnostics ;
1111using System . Reflection ;
1212using System . Reflection . Emit ;
13- using NHibernate . Linq ;
1413using NHibernate . Util ;
1514
1615namespace NHibernate . Proxy . DynamicProxy
1716{
1817 internal class DefaultMethodEmitter : IMethodBodyEmitter
1918 {
20- private static readonly MethodInfo getInterceptor ;
21-
2219 private static readonly MethodInfo handlerMethod = ReflectHelper . GetMethod < IInterceptor > (
2320 i => i . Intercept ( null ) ) ;
2421 private static readonly MethodInfo getArguments = typeof ( InvocationInfo ) . GetMethod ( "get_Arguments" ) ;
@@ -33,15 +30,12 @@ internal class DefaultMethodEmitter : IMethodBodyEmitter
3330 typeof ( object [ ] )
3431 } ) ;
3532
36- private static readonly PropertyInfo interceptorProperty = typeof ( IProxy ) . GetProperty ( "Interceptor" ) ;
37-
3833 private static readonly ConstructorInfo notImplementedConstructor = typeof ( NotImplementedException ) . GetConstructor ( new System . Type [ 0 ] ) ;
3934
4035 private readonly IArgumentHandler _argumentHandler ;
4136
4237 static DefaultMethodEmitter ( )
4338 {
44- getInterceptor = interceptorProperty . GetGetMethod ( ) ;
4539 }
4640
4741 public DefaultMethodEmitter ( ) : this ( new DefaultArgumentHandler ( ) ) { }
@@ -60,12 +54,12 @@ public void EmitMethodBody(MethodBuilder proxyMethod, MethodBuilder callbackMeth
6054 ParameterInfo [ ] parameters = method . GetParameters ( ) ;
6155 IL . DeclareLocal ( typeof ( object [ ] ) ) ;
6256 IL . DeclareLocal ( typeof ( InvocationInfo ) ) ;
63- IL . DeclareLocal ( typeof ( System . Type [ ] ) ) ;
57+ IL . DeclareLocal ( typeof ( System . Type [ ] ) ) ;
6458
6559 IL . Emit ( OpCodes . Ldarg_0 ) ;
66- IL . Emit ( OpCodes . Callvirt , getInterceptor ) ;
60+ IL . Emit ( OpCodes . Ldfld , field ) ;
6761
68- // if (interceptor == null)
62+ // if (this. interceptor == null)
6963 // return base.method(...);
7064
7165 Label skipBaseCall = IL . DefineLabel ( ) ;
@@ -90,9 +84,9 @@ public void EmitMethodBody(MethodBuilder proxyMethod, MethodBuilder callbackMeth
9084 IL . Emit ( OpCodes . Newobj , infoConstructor ) ;
9185 IL . Emit ( OpCodes . Stloc_1 ) ;
9286
93- // this.Interceptor .Intercept(info);
87+ // this.interceptor .Intercept(info);
9488 IL . Emit ( OpCodes . Ldarg_0 ) ;
95- IL . Emit ( OpCodes . Callvirt , getInterceptor ) ;
89+ IL . Emit ( OpCodes . Ldfld , field ) ;
9690 IL . Emit ( OpCodes . Ldloc_1 ) ;
9791 IL . Emit ( OpCodes . Callvirt , handlerMethod ) ;
9892
0 commit comments