I'm using a custom mvp framework, that when a view is created it tries to resolve for it's correct presenter and creates a new instance of it, but the presenter needs the view for its constructor.
Is there a way to inject dependency of the view into the constructor of the presenter using simple injector?
I've tried to use lifetime scoping but, since the view resolves/creates the presenter in its own constructor it seems that it's not resolved yet when it creates the instance of the presenter, and injects a new instance and making an infite loop and a stack overflow exception
EDIT:
The code looks something like this:
public class MyView1 : IView
{
protected IPresenter<MyView> presenter;
public MyView1()
{
/// some cocde here;
presenter = ResolvePresenterBinding();
}
IPresenter<MyView> ResolvePresenterBinding()
{
//some stuff here to resolvethe apropiate Presenter and create the instance using the IOC Container
}
}
public interface IPresenter<TView> where TView : IView
{
}
public class MyPresenter1 : IPresenter<MyView>
{
IView View;
public MyPresenter1(IView view, //other dependencies here)
{
this.View = view;
}
}