How to get generic method on closed generic type, having open MethodInfo from open generic type?

Imagine type like this (C#):

public interface IAmGeneric<T>
{
   void SoAmI<T1>(T one, T1 two);
}

Given I have open generic MethodInfo from open generic version of the type (IAmGeneric<>.SoAmI<>()) and the following array

new[] { typeof(int), typeof(string) }'

I'm looking for well performing and reliable way of getting closed version of the MethodInfo like this:

IAmGeneric<int>.SoAmI<string>()

UPDATE:

by reliable I mean it should handle cases when the method is not public, has dozen overloads, uses generic arguments from base type, not just its immediate interface etc.

8
задан Simon 18 July 2011 в 13:05
поделиться