Any help would be appreciated in this regard. I am trying to implement a wrapper of a dynamic object on top of a static type. This shell should allow me to dynamically call static functions at runtime.
For instance:
dynamic obj = new StaticDynamicWrapper(typeof(MyStaticType)); obj.DoSomething(arg1);
This is an idea. I got some online link to make it work with non-native methods and properties, but ran into various problems when โDoSomethingโ is actually a common method.
For example, if the declaration "DoSomething" was as follows:
public static RetType DoSomething<TArg>(this TArg arg1);
Or even worse, if something was supposed to have an overload with the next signature ...
public static RetType DoSomething<TArg>(this OtherGenericType<AnotherGenericType<TArg>> arg1);
So, I need to implement DynamicObject.TryInvokeMember so that the invokation method can derive at runtime based on the runtime arguments (i.e. object [] args) the correct private shared DoSomething method. In another word, I want to be able to choose the right overload and determine the right type arguments to call the MakeGenericMethod method, all at runtime.
The largest checkpoint so far shows how to map a method to public arguments with private arguments declared by parameters (ie object [] args). Can anyone help me out?
Thank you for your time!
Alwyn source share