Let's say I have an interface like this:
public interface ITest<T1, T2>
{
}
And a class like this:
public class Concrete : ITest<int, string>
{
}
Using reflection, how can I find this concrete class? I've tried the following but it doesn't work because I'm not specifying the generic type parameters.
var concretes = Assembly.GetAssembly(typeof(Concrete)).GetTypes()
.Where(x => x.IsAssignableFrom(typeof(ITest<,>))
&& !x.IsInterface);
This returns zero items. Is it even possible to do what I'm trying to do?
Aucun commentaire:
Enregistrer un commentaire