[英]How do I initialize my container when using the Common Service Factory
The Common Service Factory website specifies the following steps for its usage: Common Service Factory网站指定了以下使用步骤:
I just don't know where should I do the second to last step: Configure your IOC and setup the Common Service Adapter. 我只是不知道从哪里开始倒数第二步:配置您的IOC并设置公共服务适配器。
Does anyone has an example of how to use the Common Service Factory? 有没有人有一个如何使用公共服务工厂的例子?
Thanks a lot. 非常感谢。
You typically setup your container in the startup path of your application. 您通常在应用程序的启动路径中设置容器。 For a ASP.NET application for instance, this would typically be the
Application_Start
event. 例如,对于ASP.NET应用程序,这通常是
Application_Start
事件。 After you created the container, you wrap the container into a Common Service Locator adapter for the given container and supply it to the ServiceLocator.SetLocatorProvider
of the CSL project and you're done. 在创建容器之后,将容器包装到给定容器的Common Service Locator适配器中,并将其提供给CSL项目的
ServiceLocator.SetLocatorProvider
,您就完成了。
This is how it looks like when using Simple Injector: 这是使用Simple Injector时的样子:
var adapter =
new SimpleInjectorServiceLocatorAdapter(container);
ServiceLocator.SetLocatorProvider(() => adapter);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.