我正在探索 MEF2/.Net4.5(又名约定)的新的无属性注册功能。更具体地说,我正在尝试注册开放泛型:
public interface IRepository<T>
{
    T Fetch();
}
public class Repository<T> : IRepository<T>
{
    public T Fetch()
    {
        return default(T);
    }
}
public class Quotation
{
}
class Program
{
    static void Main(string[] args)
    {
       var registrationBuilder = new RegistrationBuilder();
       registrationBuilder
            .ForType<Repository<Quotation>>()
            .Export();
        registrationBuilder
            .ForTypesMatching(t => t.Name.EndsWith("ory"))
            .Export();
        registrationBuilder
            .ForType<Quotation>()
            .Export<Quotation>();
        var catalog = new AssemblyCatalog(typeof (Program).Assembly, registrationBuilder);
        foreach (var part in catalog.Parts)
        {
            Console.WriteLine(part.ToString());
        }
     }
 }
无论我使用哪种方法来注册存储库(参见代码),目录中都只包含 Quotation 类。我是否遗漏了什么,或者注册 API 中不支持开放泛型?
此致,
K·科塞利斯