Skip to content

Instantly share code, notes, and snippets.

@glikoz
Created May 31, 2012 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glikoz/2844693 to your computer and use it in GitHub Desktop.
Save glikoz/2844693 to your computer and use it in GitHub Desktop.
Usage of Container out of Controller
public class MyProvider
{
public IRepository MyRepository {get;set;}
public MyProvider()
{
// Registration made in AppHost as container.Register<IRepository>(c => new MyRepository ());
MyRepository= new Container().Resolve(IRepository); // a)Concrete Service Locator
MyRepository= Funq.Container.Resolve(IRepository); // b)Service Locator check this http://blog.ploeh.dk/2010/02/03/ServiceLocatorIsAnAntiPattern.aspx
// c) Another way
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment