public
Created

Usage of Container out of Controller

  • Download Gist
Test.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14
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
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.