2015-01-04 33 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

相关问题