comparison Source/Data/Linq/ReflectionHelper.cs @ 4:f757da6161a1

!bug 100 + 2h fixed gregression
author cin
date Sun, 24 Aug 2014 17:57:42 +0400
parents 1ef98bd70424
children
comparison
equal deleted inserted replaced
3:1ef98bd70424 4:f757da6161a1
40 40
41 //if (ex is MemberExpression) 41 //if (ex is MemberExpression)
42 // return ((PropertyInfo)((MemberExpression)ex).Member).GetGetMethod(); 42 // return ((PropertyInfo)((MemberExpression)ex).Member).GetGetMethod();
43 43
44 /// HACK 44 /// HACK
45 var mce = (MethodCallExpression)ex; 45 return ExtractMethodInfo ((MethodCallExpression)ex);
46 var mi = mce.Method;
47 if (mi.IsVirtual && mi.DeclaringType != mce.Object.Type)
48 mi = mce.Object.Type.GetMethod(mi.Name, mi.GetParameters().Select(p => p.ParameterType).ToArray());
49
50 return mi;
51 } 46 }
52 } 47 }
53 48
54 public static MemberInfo MemeberInfo(LambdaExpression func) 49 public static MemberInfo MemeberInfo(LambdaExpression func)
55 { 50 {
64 (MemberInfo)((NewExpression) ex).Constructor; 59 (MemberInfo)((NewExpression) ex).Constructor;
65 } 60 }
66 61
67 public static MethodInfo ExtractMethodInfo(MethodCallExpression mce) { 62 public static MethodInfo ExtractMethodInfo(MethodCallExpression mce) {
68 var mi = mce.Method; 63 var mi = mce.Method;
69 if (mi.IsVirtual && mi.DeclaringType != mce.Object.Type) 64 if (mi.IsVirtual && mi.DeclaringType != mce.Object.Type && !mce.Object.Type.IsInterface)
70 mi = mce.Object.Type.GetMethod(mi.Name, mi.GetParameters().Select(p => p.ParameterType).ToArray()); 65 mi = mce.Object.Type.GetMethod(mi.Name, mi.GetParameters().Select(p => p.ParameterType).ToArray());
71 66
72 return mi; 67 return mi;
73 } 68 }
74 69