10
10
using System . Diagnostics ;
11
11
using System . Reflection ;
12
12
using System . Reflection . Emit ;
13
- using NHibernate . Linq ;
14
13
using NHibernate . Util ;
15
14
16
15
namespace NHibernate . Proxy . DynamicProxy
17
16
{
18
17
internal class DefaultMethodEmitter : IMethodBodyEmitter
19
18
{
20
- private static readonly MethodInfo getInterceptor ;
21
-
22
19
private static readonly MethodInfo handlerMethod = ReflectHelper . GetMethod < IInterceptor > (
23
20
i => i . Intercept ( null ) ) ;
24
21
private static readonly MethodInfo getArguments = typeof ( InvocationInfo ) . GetMethod ( "get_Arguments" ) ;
@@ -33,15 +30,12 @@ internal class DefaultMethodEmitter : IMethodBodyEmitter
33
30
typeof ( object [ ] )
34
31
} ) ;
35
32
36
- private static readonly PropertyInfo interceptorProperty = typeof ( IProxy ) . GetProperty ( "Interceptor" ) ;
37
-
38
33
private static readonly ConstructorInfo notImplementedConstructor = typeof ( NotImplementedException ) . GetConstructor ( new System . Type [ 0 ] ) ;
39
34
40
35
private readonly IArgumentHandler _argumentHandler ;
41
36
42
37
static DefaultMethodEmitter ( )
43
38
{
44
- getInterceptor = interceptorProperty . GetGetMethod ( ) ;
45
39
}
46
40
47
41
public DefaultMethodEmitter ( ) : this ( new DefaultArgumentHandler ( ) ) { }
@@ -60,12 +54,12 @@ public void EmitMethodBody(MethodBuilder proxyMethod, MethodBuilder callbackMeth
60
54
ParameterInfo [ ] parameters = method . GetParameters ( ) ;
61
55
IL . DeclareLocal ( typeof ( object [ ] ) ) ;
62
56
IL . DeclareLocal ( typeof ( InvocationInfo ) ) ;
63
- IL . DeclareLocal ( typeof ( System . Type [ ] ) ) ;
57
+ IL . DeclareLocal ( typeof ( System . Type [ ] ) ) ;
64
58
65
59
IL . Emit ( OpCodes . Ldarg_0 ) ;
66
- IL . Emit ( OpCodes . Callvirt , getInterceptor ) ;
60
+ IL . Emit ( OpCodes . Ldfld , field ) ;
67
61
68
- // if (interceptor == null)
62
+ // if (this. interceptor == null)
69
63
// return base.method(...);
70
64
71
65
Label skipBaseCall = IL . DefineLabel ( ) ;
@@ -90,9 +84,9 @@ public void EmitMethodBody(MethodBuilder proxyMethod, MethodBuilder callbackMeth
90
84
IL . Emit ( OpCodes . Newobj , infoConstructor ) ;
91
85
IL . Emit ( OpCodes . Stloc_1 ) ;
92
86
93
- // this.Interceptor .Intercept(info);
87
+ // this.interceptor .Intercept(info);
94
88
IL . Emit ( OpCodes . Ldarg_0 ) ;
95
- IL . Emit ( OpCodes . Callvirt , getInterceptor ) ;
89
+ IL . Emit ( OpCodes . Ldfld , field ) ;
96
90
IL . Emit ( OpCodes . Ldloc_1 ) ;
97
91
IL . Emit ( OpCodes . Callvirt , handlerMethod ) ;
98
92
0 commit comments