diff Source/Data/Linq/ReflectionHelper.cs @ 3:1ef98bd70424

!bug 100 +3h Исправление проблемы BLToolkit + mono 3.4
author cin
date Fri, 22 Aug 2014 17:34:46 +0400
parents f990fcb411a9
children f757da6161a1
line wrap: on
line diff
--- a/Source/Data/Linq/ReflectionHelper.cs	Fri Aug 22 13:41:57 2014 +0400
+++ b/Source/Data/Linq/ReflectionHelper.cs	Fri Aug 22 17:34:46 2014 +0400
@@ -41,7 +41,13 @@
 				//if (ex is MemberExpression)
 				//	return ((PropertyInfo)((MemberExpression)ex).Member).GetGetMethod();
 
-				return ((MethodCallExpression)ex).Method;
+				/// HACK
+				var mce = (MethodCallExpression)ex;
+				var mi = mce.Method;
+				if (mi.IsVirtual && mi.DeclaringType != mce.Object.Type)
+					mi = mce.Object.Type.GetMethod(mi.Name, mi.GetParameters().Select(p => p.ParameterType).ToArray());
+
+				return mi;
 			}
 		}
 
@@ -54,10 +60,18 @@
 
 			return
 				ex is MemberExpression     ? ((MemberExpression)    ex).Member :
-				ex is MethodCallExpression ? ((MethodCallExpression)ex).Method :
+				ex is MethodCallExpression ? ExtractMethodInfo((MethodCallExpression)ex) :
 				                 (MemberInfo)((NewExpression)       ex).Constructor;
 		}
 
+		public static MethodInfo ExtractMethodInfo(MethodCallExpression mce) {
+			var mi = mce.Method;
+			if (mi.IsVirtual && mi.DeclaringType != mce.Object.Type)
+				mi = mce.Object.Type.GetMethod(mi.Name, mi.GetParameters().Select(p => p.ParameterType).ToArray());
+
+			return mi;
+		}
+
 		public class Binary : Expressor<BinaryExpression>
 		{
 			public static MethodInfo Conversion = PropertyExpressor(e => e.Conversion);