Thursday, 6 May 2010

Service Locator Pattern

  • It's a design pattern for simplifying dependency injection
  • The ServiceLocator class would be a singleton class whose object contains a dictionary of all dependencies in the project
  • the main point of using ServiceLocator is to make the dependencies easily replaceable at runtime
  • It can be used along with other IoC containers - IoC containers are good to initialize dependencies whereas service locator can help replacing the dependencies at runtime after initialization when needed

http://simpleservicelocator.codeplex.com/

The problem with this is that if there is any ref-type property, this doesn't work. Which means every ref-type property must implement its own Equals.

No comments: