title: NInject with Generic interface
body: <p>I have defined one interface and one class:</p>
  
  <pre><code>public interface IRepository&lt;T&gt;
  {
  }
  
  public class RoleRepository:IRepository&lt;Domain_RoleInfo&gt;
  {
  }
  </code></pre>
  
  <p>Inject here:</p>
  
  <pre><code>public RoleService
  {
      [Inject]
      public RoleService(IRepository&lt;Domain_RoleInfo&gt; rep)
      {
          _roleRep=rep;
      }
  }
  </code></pre>
  
  <p>How can I perform Dependency Injection With Ninject,say how to bind?</p>
  
  <p>I have written a helper class as below, it works fine with non-generic interface.but how to refactor it support generic interface as above?</p>
  
  <pre><code>public class RegisterNinjectModule : NinjectModule
  {
      public override void Load()
      {
          BindServices();
          BindRepositories();
      }
  
      private void BindServices()
      {
  
          FindAndBindInterfaces("RealMVC.Service.Interfaces", "RealMVC.Services");            
      }
  
      private void BindRepositories()
      {
          FindAndBindInterfaces("RealMVC.Repository.Interfaces", "RealMVC.Repositories");   
      }
  
      private void FindAndBindInterfaces(string interfaceAssemblyName, string implAssemblyName)
      {
          //Get all interfaces
          List&lt;Type&gt; interfaces = Assembly.Load(interfaceAssemblyName).GetTypes().AsQueryable().Where(x =&gt; x.IsInterface).ToList();
          IQueryable&lt;Type&gt; ts = Assembly.Load(implAssemblyName).GetTypes().AsQueryable().Where(x =&gt; x.IsClass);
  
          foreach (Type intf in interfaces)
          {
              Type t = ts.Where(x =&gt; x.GetInterface(intf.Name) != null).FirstOrDefault();
              if (t != null)
              {
                  Bind(intf).To(t).InSingletonScope();
              }
          }
      }
  
  
  }
  </code></pre>