Question

I am building a proof of concept webformsmvp site. I want to use Ninject (v3.0) to resolve my service (and any other) dependencies when creating the Presenters. Here is an example of my Presenter constructor:

public ParticipantPresenter(IParticipantDisplayView view, IParticipantService participantService) : base(view)

So, I want to have Ninject resolve the IParticipantService implementation using a custom IPresenterFactory.

For reference, here is the signature of the method on the IPresenterFactory interface that needs to be implemented:

IPresenter Create(Type presenterType, Type viewType, IView viewInstance); 

I have a question; if I implement and register my IPresenterFactory implementation am I responsible for resolving the View argument in the Presenter constructor? Doesn't the webformsmvp framework take care of this for me, or now that I am opting to provide a custom factory implementation, do I now take on the responsibility of resolving the view?

P.S. I noticed that there is an implementation on the webformsmvp contrib project but this is for Ninject v2. I have been looking at re-writing the code for Ninject3. But this doesn't help me answer the question.

Was it helpful?

Solution

After having a play around it turns out that if you implement your own IPresenterFactory you are not responsible for resolving the View. Looking at the signature (same as above):

IPresenter Create(Type presenterType, Type viewType, IView viewInstance);

the viewInstance contains the instance of the view as resolved by the webformsmvp framework. I guess you have the opportunity to do something with this instance here in your factory implementation.

All I need to do in my factory is resolve the presenterType and I do this by delegating to the Ninject kernel.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top