我在 ExirRobot.Infrastructure 中使用 LightInject(C# 中的轻量级 IOC 容器)作为我的解决方案资源管理器中的全局 IOC 容器项目(图片已附加)。我想在 ExirRobot.WebApi 项目中注册 Ioc Config Class(IOC.cs)以便注入服务层接口(如 IArticleService)到 web api 控制器,我该怎么做?
国际奥委会.cs:
public class IOC{
public static void Initialize()
{
var container = new LightInject.ServiceContainer();
//Engin Dependency Wiring
container.Register<ISISearchResult, ISIContentProvider>(new PerRequestLifeTime());
container.Register<ISearchArticleEngine, ISIEngineManager>(new PerRequestLifeTime());
//Repository Dependency Wiring
container.Register<IArticleRepository, ArticleRepository>(new PerRequestLifeTime());
container.Register<IAuthorRepository, AuthorRepository>(new PerRequestLifeTime());
container.Register<IIsiArticleDetailRepository, IsiArticleDetailRepository>(new PerRequestLifeTime());
container.Register<IJournalRepository, JournalRepository>(new PerRequestLifeTime());
container.Register<IVendorRepository, VendorRepository>(new PerRequestLifeTime());
//Service Dependency Wiring
container.Register<IArticleService, ArticleService>(new PerRequestLifeTime());
container.Register<IAuthorService, AuthorService>(new PerRequestLifeTime());
container.Register<IIsiArticleDetailService, IsiArticleDetailService>(new PerRequestLifeTime());
container.Register<IJournalService, JournalService>(new PerRequestLifeTime());
container.Register<IVendorService, VendorService>(new PerRequestLifeTime());
}
}