castle IOC - resolving circular references

Posted by Frederik on Stack Overflow See other posts from Stack Overflow or by Frederik
Published on 2009-11-23T13:27:37Z Indexed on 2010/12/25 10:54 UTC
Read the original article Hit count: 406

Filed under:
|
|

Hi

quick question for my MVP implementation:

currently I have the code below, in which both the presenter and view are resolved via the container.
Then the presenter calls View.Init to pass himself to the view.

I was wondering however if there is a way to let the container fix my circular reference (view -> presenter, presenter -> view).

class Presenter : IPresenter {
   private View _view; 

   public Presenter(IView view, ...){
    _view = view;
    _view.Init(this)
   }
}

class View : IView {
 private IPresenter _presenter;
 public void Init(IPresenter presenter){
  _presenter = presenter;
 }
}

Kind regards

Frederik

© Stack Overflow or respective owner

Related posts about c#

Related posts about castle-windsor