- Add the CommonServiceLocator and Unity packages to the project using Nuget.
- Add the following initialisation code (for example in Application_Start):
UnityContainer container = new UnityContainer(); //configure container ... var unityServiceLocator = new UnityServiceLocator(container); ServiceLocator.SetLocatorProvider(() => unityServiceLocator);
- Use the IServiceLocator and ServiceLocator interface and class for DI and service location, respectively.
Tuesday, March 22, 2011
Setting up Unity in a new project
Using the Common Service Locator and Unity is fairly simple with Nuget. This post records the steps in case I need them again.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment