Hello,
This is my first post so be nice
I want to integrate Spring.NET as with WebformMVP (http://webformsmvp.codeplex.com). To do that I must implement an interface called IPresenterFactory. That interface has a method called Create that I need to implement.
Inside this method I would need to create the presenterType with spring and pass viewInstance to the constructor of presenterType.Code:IPresenter Create(Type presenterType, Type viewType, IView viewInstance);
Here is the implementation for Castle Windsor:
SimpleCode:public IPresenter Create(Type presenterType, Type viewType, IView viewInstance) { if (presenterType == null) throw new ArgumentNullException("presenterType"); if (viewType == null) throw new ArgumentNullException("viewType"); if (viewInstance == null) throw new ArgumentNullException("viewInstance"); var parameters = new Dictionary<string, object> { { "view", viewInstance } }; return (IPresenter)presenterKernel.Resolve(presenterType, parameters); }Not so much with Spring.NET. I can make it work but then I can't do constructor injection on the presenter because it complains that it does not have a constructor with only 1 argument. In the object definition I also need to put the constructor argument which I do not need because the framework constructs that for me.
So my question would be: How can I do this so that I'm able to do constructor injection?Code:<object id="SomePresenter" type="SomeProject.Presenters.SomePresenter, SomeProject"> <constructor-arg name="view" ref="SomePresenterView" /> </object> <object id="SomePresenterView" type="SomPresenterView.aspx"></object>
A plus would be to eliminate the need of the constructor-arg that will not be used.
Thanks, Ivica



Reply With Quote