Reputation: 9143
I have method:
public ActionResult Index(IEmailRepository myEmails)
I want to inject into method parameter unsing castle windsor.
I have mapping that insert the mapped class into constructor,
container.Register(
Component.For<IEmailRepository>().ImplementedBy<EmailRepository>().LifeStyle.PerWebRequest);
but i do not know how to do this into method.
Any ideas?
Upvotes: 0
Views: 266
Reputation: 14677
You don't do it in the method -- you do it in the constructor and hold on to the reference in a class-level variable:
private IEmailRepository emailRepository;
public YourClassConstructor(IEmailRepository myEmails)
{
this.emailRepository = myEmails;
}
public ActionResult Index()
{
// use the emailRepository
}
Upvotes: 2