麻烦详细解释一下这段c#代码?
privateIKernelinversionKernel;publicInversionControllerFactory(){inversionKernel=newS...
private IKernel inversionKernel;
public InversionControllerFactory()
{
inversionKernel = new StandardKernel();
AddBinds();
}
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
{
return controllerType == null
? null
: (IController)inversionKernel.Get(controllerType);
}
private void AddBinds()
{
} 展开
public InversionControllerFactory()
{
inversionKernel = new StandardKernel();
AddBinds();
}
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
{
return controllerType == null
? null
: (IController)inversionKernel.Get(controllerType);
}
private void AddBinds()
{
} 展开
2个回答
展开全部
private IKernel inversionKernel; //声明一个实现IKernel接口的变量
//构造函数
public InversionControllerFactory()
{
//创建一个StandardKernel类型的实例并赋值给inversionKernel
inversionKernel = new StandardKernel();
//调用函数AddBinds
AddBinds();
}
//重写方法GetControllerInstance
//查看InversionControllerFactory的父类或实现的接口
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
{
//判断参数controllerType是否为null
//为null则返回null
//不为null则调用StandardKernel类中的Get方法并返回结果
return controllerType == null
? null
: (IController)inversionKernel.Get(controllerType);
}
private void AddBinds()
{
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询