Rohan,
No, it is not possible by default.
presenter.SetView(this) is the easier.

On Fri, Apr 17, 2009 at 4:52 AM, Rohan <[email protected]> wrote:

>
> Hi guys, I am pretty new to the Castle project and I have a quick
> question about circular dependencies.
>
> I am trying to implement the MVPC design pattern using the following
> reference document
>
> http://www.martinhunter.co.nz/articles/MVPC.pdf
>
> This pattern requires the View to reference the Presenter and the
> Presenter to reference the View.  Is there any way to have these
> dependencies resolved. I am thinking that it wont be possible, what
> would be an elegant work around?
>
> Thanks
>
> Rohan
>
> IWindsorContainer container = new WindsorContainer();
>
> container.Register(Component.For<Presenter>());
> container.Register(Component.For<Controller>());
> container.Register(Component.For<Model>());
> container.Register(Component.For<View>());
>
> Application.Run(container.Resolve<View>());
>
> public partial class View : Form
> {
>    private readonly Presenter _presenter;
>
>    private View()
>    {
>        InitializeComponent();
>    }
>
>    public View(Presenter presenter) : this()
>    {
>        _presenter = presenter;
>    }
> }
>
> public class Presenter
> {
>    private readonly Model _model;
>    private readonly Controller _controller;
>
>    public Presenter(View view, Model model, Controller controller)
>    {
>        _model = model;
>        _controller = controller;
>    }
> }
>
> public class Model
> {
>    private int _value;
>
>    public Model(int value)
>    {
>        _value = value;
>    }
>
>    public int Value
>    {
>        get { return _value; }
>        set
>        {
>            if (_value != value)
>            {
>                _value = value;
>                this.OnValueChanged(_value);
>            }
>        }
>    }
>
>    protected virtual void OnValueChanged(int value)
>    {
>        Action<int> eventhandler = this.ValueChanged;
>        if (eventhandler != null)
>        {
>            eventhandler(value);
>        }
>    }
>
>    public event Action<int> ValueChanged;
> }
>
> public class Controller
> {
>    private readonly Model _model;
>
>    public Controller(Model model)
>    {
>        _model = model;
>    }
> }
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to