2015-01-04 30 views
0

我有此代碼錯誤ninject類型「T」必須是可轉化爲「T」,以便以通用方法用它作爲一個參數「T」

public class NinjectControllerFactory : DefaultControllerFactory 
{ 

    private IKernel ninjectKernel; 
    public NinjectControllerFactory() 
    { 
     ninjectKernel = new StandardKernel(); 
     AddBindings(); 
    } 

    protected override IController GetControllerInstance(
     RequestContext requestContext, Type controllerType) 
    { 
     return controllerType == null 
      ? null 
      : (IController)ninjectKernel.Get(controllerType); 
    } 

    private void AddBindings() 
    { 
     ninjectKernel 
      .Bind<ICollection>(). 
      To<ListOfProcess.ConnectionLogic.ConnectionLogic>(); 
    } 
} 

並且在最後一行下一個錯誤: 類型「T」必須可轉換爲「T」才能在通用方法中將其用作參數「T」。

回答

1

好像ListOfProcess.ConnectionLogic.ConnectionLogic沒有執行ICollection

(如果它是一個嵌套類型:不ListOfProcess,不ListOfProcess.ConnectionLogicListOfProcess.ConnectionLogic.ConnectionLogic是不執行所述一個ICollection

相關問題