diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-03-10 06:03:25 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-03-10 06:03:25 +0100 |
| commit | 523a04de5252ae089e52eeaf9c8d83a5e0676731 (patch) | |
| tree | 4498dc0edfa1e5b101807bdc85061884bda3dac2 /src/CompilerServices/CompilerServices.cs | |
| parent | 991a840bf9bc92ddc76e9e9961706168328a211b (diff) | |
getStremFromPath made instanced for overriding in designiface, crowide wip
Diffstat (limited to 'src/CompilerServices/CompilerServices.cs')
| -rw-r--r-- | src/CompilerServices/CompilerServices.cs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs index 12a020ff..e315f761 100644 --- a/src/CompilerServices/CompilerServices.cs +++ b/src/CompilerServices/CompilerServices.cs @@ -276,7 +276,11 @@ namespace Crow.IML #region Reflexion helpers static MemberInfo getMemberInfoWithReflexion(object instance, string member){ - return instance.GetType ().GetMember (member)?.FirstOrDefault(); + Type t = instance.GetType(); + MemberInfo mi = t.GetMember (member)?.FirstOrDefault(); + if (mi == null) + mi = CompilerServices.SearchExtMethod (t, member); + return mi; } static MethodInfo getMethodInfoWithReflexion(object instance, string method){ return instance.GetType ().GetMethod (method, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); @@ -344,12 +348,20 @@ namespace Crow.IML PropertyInfo pi = mi as PropertyInfo; tmp = pi.GetValue (instance); dstType = pi.PropertyType; - } - if (mi.MemberType == MemberTypes.Field) { + }else if (mi.MemberType == MemberTypes.Field) { FieldInfo fi = mi as FieldInfo; tmp = fi.GetValue (instance); dstType = fi.FieldType; + }else if (mi.MemberType == MemberTypes.Method) { + MethodInfo gi = mi as MethodInfo; + if (gi.IsStatic) + tmp = gi.Invoke(null, new object[] {instance}); + else + tmp = gi.Invoke(instance, null); + dstType = gi.ReturnType; } + + if (tmp != null) return tmp; if (dstType == typeof(string) || dstType == CompilerServices.TObject)//TODO:object should be allowed to return null and not "" @@ -693,7 +705,7 @@ namespace Crow.IML /// <summary> /// create delegate helper /// </summary> - static Delegate createDel(Type eventType, object instance, string method){ + static Delegate createDel(object instance, Type eventType, string method){ Type t = instance.GetType (); MethodInfo mi = t.GetMethod (method, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (mi == null) { |