1 Star 0 Fork 2

王占超/LIMS

forked from shamork/LIMS 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
NinjectControllerFactory.cs 2.28 KB
一键复制 编辑 原始数据 按行查看 历史
Wlasovets 提交于 2017-08-07 19:48 . first commit
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BusinessLogic.Implementations;
using BusinessLogic.Interfaces;
using Domain;
using Ninject;
namespace Web
{
public class NinjectControllerFactory : DefaultControllerFactory
{
private IKernel ninjectKernel;
public NinjectControllerFactory()
{
ninjectKernel = new StandardKernel();
AddBindings();
}
//Извлекаем экземпляр контроллера для заданного контекста запроса и типа контроллера
protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType)
{
return controllerType == null ? null : (IController) ninjectKernel.Get(controllerType);
}
//Определяем все привязки
private void AddBindings()
{
ninjectKernel.Bind<IAdmissibleLevelsRepository>().To<EFAdmissibleLevelsRepository>();
ninjectKernel.Bind<ICertificatesRepository>().To<EFCertificatesRepository>();
ninjectKernel.Bind<IConditionsRepository>().To<EFConditionsRepository>();
ninjectKernel.Bind<IDirectionsRepository>().To<EFDirectionsRepository>();
ninjectKernel.Bind<IEmployeesRepository>().To<EFEmployeesRepository>();
ninjectKernel.Bind<IGagesRepository>().To<EFGagesRepository>();
ninjectKernel.Bind<IIndicatorsRepository>().To<EFIndicatorsRepository>();
ninjectKernel.Bind<IResultsRepository>().To<EFResultsRepository>();
ninjectKernel.Bind<ISamplesRepository>().To<EFSamplesRepository>();
ninjectKernel.Bind<ISelectedSamplesRepository>().To<EFSelectedSamplesRepository>();
ninjectKernel.Bind<ITechnicalRegulationsRepository>().To<EFTechnicalRegulationsRepository>();
ninjectKernel.Bind<EFDbContext>().ToSelf().WithConstructorArgument("connectionString",
ConfigurationManager.ConnectionStrings[0]
.ConnectionString);
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/shenzhiziyi/LIMS.git
git@gitee.com:shenzhiziyi/LIMS.git
shenzhiziyi
LIMS
LIMS
master

搜索帮助