title: Dynamically infer generic types via. reflection
body: <p>Any help would be appreciated on this one. I'm trying to implement a dynamic object wrapper over  a static type. This wrapper should then allow me to call static functions dynamically at run time.</p>
  
  <p>For example:</p>
  
  <pre><code>dynamic obj = new StaticDynamicWrapper(typeof(MyStaticType));
  obj.DoSomething(arg1);
  </code></pre>
  
  <p>That's the idea. I got some online reference to get it to work on non-generic method and property but ran into various issues when "DoSomething" is actually a generic method.</p>
  
  <p>For example, if the declaration of the "DoSomething" were as follow:</p>
  
  <pre><code>public static RetType DoSomething&lt;TArg&gt;(this TArg arg1);
  </code></pre>
  
  <p>Or even worse if do something were to have an overload with the following signature...</p>
  
  <pre><code>public static RetType DoSomething&lt;TArg&gt;(this OtherGenericType&lt;AnotherGenericType&lt;TArg&gt;&gt; arg1);
  </code></pre>
  
  <p>So I need to implement the DynamicObject.TryInvokeMember in such a way that the method invokation is able to infer at runtime, based on the runtime arguments (ie. object[] args), the correct closed generic method of DoSomething. In another word I wanna be able to select the correct overload and determines the correct type arguments to call MakeGenericMethod with, all that at runtime. </p>
  
  <p>The biggest roadblock so far, is figuring out how to map the method's open generic arguments to the closed types arguments declared by the parameter arguments (ie. object[] args). Can anyone out there help me out?</p>
  
  <p>Thanks for your time!</p>