public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { try { if(args != null) for(int a = 0; a < args.Length; a++) if(args[a] is DynamicInvokeObject) args[a] = ((DynamicInvokeObject)args[a])._obj; result = _t.InvokeMember(binder.Name, BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static, null, _obj, args); if(result == null) return true; Type t = result.GetType(); if(t.IsPrimitive == false && t != typeof(string)) result = new DynamicInvokeObject(result); return true; } catch(Exception exc) { if(exc is TargetInvocationException) exc = exc.InnerException; string s = String.Format("{0}: {1}", binder.Name, exc.Message); throw new DynamicInvokeException(s); } //return base.TryInvokeMember(binder, args, out result); }
public override bool TryGetMember(GetMemberBinder binder, out object result) { try { result = _t.InvokeMember(binder.Name, BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static, null, _obj, null); if(result == null) return false; Type t = result.GetType(); if(t.IsPrimitive == false && t != typeof(string)) result = new DynamicInvokeObject(result); return true; } catch(Exception exc) { if(exc is TargetInvocationException) exc = exc.InnerException; string s = String.Format("{0}: {1}", binder.Name, exc.Message); throw new DynamicInvokeException(s); } //return base.TryGetMember(binder, out result); }