注册 类 使用 ninject 实现通用接口

registering classes implementing a generic interface using ninject

我有这个界面:

   public interface IObjectFactory<T>
   {
      T NewObject();
   }

我可以有多个 类 来实现这个接口,像这样

   public class UserFactory : IObjectFactory<IUser>
   {
      public IUser NewObject() => new User(); 
   }

我想扫描所有程序集以绑定所有 类 以便我可以使用 without 创建直接绑定指令。
我遇到的问题是通用接口,普通示例不起作用。
我该如何解决?

使用ninject.extensions.conventions.

kernel.Bind(
    c => c.FromThisAssembly()
        .SelectAllClasses()
        .InheritedFrom(typeof(IObjectFactory<>))
        .BindAllInterfaces());