When Controller1 is created, I want IService to be mapped to ConcreteService1 and IPageService to ConcretePageService1
And when Controller2 is created, I want IService to be mapped to ConcreteService2 and IPageService to ConcretePageService2
How can I initialize an ObjectFactory so that the above works?
While I initialized ObjectFactory as follows:
ObjectFactory.Initialize(x => { x.For<IService>().Use<ConcreteService1>(); x.For<IPageService>().Use<ConcretePageService1>(); });
But it ALWAYS maps ConcreteService1 to IService and ConcretePageService1 to IPageService regardless of controller type
public class Controller1 : Controller { public Controller1(IService service, IPageService pageService) { } } public class Controller2 : Controller { public Controller2(IService service, IPageService pageService) { } } public interface IService { } public class ConcreteService1:IService { } public class ConcreteService2:IService { } public interface IPageService { } public class ConcretePageService1:IPageService { } public class ConcretePageService2:IPageService { }
c # structuremap
theateist
source share