boca
boca

Reputation: 2352

How do I initialize my container when using the Common Service Factory

The Common Service Factory website specifies the following steps for its usage:

I just don't know where should I do the second to last step: Configure your IOC and setup the Common Service Adapter.

Does anyone has an example of how to use the Common Service Factory?

Thanks a lot.

Upvotes: 0

Views: 1139

Answers (1)

Steven
Steven

Reputation: 172825

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. 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.

This is how it looks like when using Simple Injector:

var adapter = 
    new SimpleInjectorServiceLocatorAdapter(container);

ServiceLocator.SetLocatorProvider(() => adapter);

Upvotes: 2

Related Questions