Mercurial > pub > bltoolkit
comparison 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 |
comparison
equal
deleted
inserted
replaced
2:79a04c6442bf | 3:1ef98bd70424 |
---|---|
39 ex = ((UnaryExpression)ex).Operand; | 39 ex = ((UnaryExpression)ex).Operand; |
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 return ((MethodCallExpression)ex).Method; | 44 /// HACK |
45 var mce = (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; | |
45 } | 51 } |
46 } | 52 } |
47 | 53 |
48 public static MemberInfo MemeberInfo(LambdaExpression func) | 54 public static MemberInfo MemeberInfo(LambdaExpression func) |
49 { | 55 { |
52 if (ex is UnaryExpression) | 58 if (ex is UnaryExpression) |
53 ex = ((UnaryExpression)ex).Operand; | 59 ex = ((UnaryExpression)ex).Operand; |
54 | 60 |
55 return | 61 return |
56 ex is MemberExpression ? ((MemberExpression) ex).Member : | 62 ex is MemberExpression ? ((MemberExpression) ex).Member : |
57 ex is MethodCallExpression ? ((MethodCallExpression)ex).Method : | 63 ex is MethodCallExpression ? ExtractMethodInfo((MethodCallExpression)ex) : |
58 (MemberInfo)((NewExpression) ex).Constructor; | 64 (MemberInfo)((NewExpression) ex).Constructor; |
65 } | |
66 | |
67 public static MethodInfo ExtractMethodInfo(MethodCallExpression mce) { | |
68 var mi = mce.Method; | |
69 if (mi.IsVirtual && mi.DeclaringType != mce.Object.Type) | |
70 mi = mce.Object.Type.GetMethod(mi.Name, mi.GetParameters().Select(p => p.ParameterType).ToArray()); | |
71 | |
72 return mi; | |
59 } | 73 } |
60 | 74 |
61 public class Binary : Expressor<BinaryExpression> | 75 public class Binary : Expressor<BinaryExpression> |
62 { | 76 { |
63 public static MethodInfo Conversion = PropertyExpressor(e => e.Conversion); | 77 public static MethodInfo Conversion = PropertyExpressor(e => e.Conversion); |