c# - Invoke object method regardless of parameter type -


i using dynamicobject wrap internal object , mask generics, when try invoke methods on internal object require typed paramaters, treating paramaters type object invoke fails.

code:

public override bool tryinvokemember(invokememberbinder binder, object[] args, out object result)         {             try             {                 result = minternalobject.gettype().invokemember(binder.name, (bindingflags.invokemethod | bindingflags.instance | bindingflags.public), null, minternalobject, args);                 return true;             }             catch (exception)             {                 return base.tryinvokemember(binder, args, out result);             }         } 

so basically, wondering how make ignore paramater types , invoke method object anyway, sugestions?

i suspect want along lines of (psuedo code, simplified):

var mem = internalobject.gettype().getmember(binder.name); if (mem.isgenericdefinition)   mem = mem.makegeneric(array.convert(args, x => x.gettype())); var result = mem.invoke(null, internalobject, args); 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -