Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 297361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:37:57+00:00 2026-05-12T06:37:57+00:00

I am tying to register a component into the IWindsorContainer i.e. _container.Register(Component.For<IView>().ImplementedBy<View>()); _container.Register(Component.For<Presenter>()); When

  • 0

I am tying to register a component into the IWindsorContainer i.e.

_container.Register(Component.For<IView>().ImplementedBy<View>());
_container.Register(Component.For<Presenter>());

When i resolve the view i want to also want to create the Presenter so that i can subscribe to any events that are generated by the view. Can this be accomplished during the registration process or do i need some kind of Facility?

public interface IView
{
  event Action<string> Process;
}

public class View : IView
{
  public event Action<string> Process;
}

public class Presenter
{
  public Presenter(IView view)
  {
    view.Process += (args) => this.DoSomeStuff();
  }
}

I have written a custom registration but its not working as expected

public class ViewRegistration<TView> : IRegistration where TView : IView
{
    private Type _implementation, _presenter;

    public ViewRegistration<TView> ImplementedBy<TImplementation>() where TImplementation : TView
    {
        _implementation = typeof(TImplementation);
        return this;
    }

    public ViewRegistration<TView> Using<TPresenter>()
    {
        _presenter = typeof(TPresenter);
        return this;
    }

    public void Register(IKernel kernel)
    {
        var model = kernel.ComponentModelBuilder.BuildModel(_implementation.FullName, typeof(TView), _implementation, null);
        if (_presenter != null)
        {
            var test = kernel.ComponentModelBuilder.BuildModel(_presenter.FullName, _presenter, _presenter, null);

            model.AddDependent(test);
        }
        kernel.AddCustomComponent(model);            
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:37:58+00:00Added an answer on May 12, 2026 at 6:37 am

    Usually I do this differently:

    1. View gets the Presenter injected in the constructor. This way you ensure both are created at the same time (when you resolve IView from the container)
    2. The presenter does not receive the view in the constructor. Rather, I add the code to assign it in the View’s constructor explicitly:
    public View(Presenter presenter)
    {
       this.presenter = presenter;
       presenter.AssignView (this);
    }
    

    Of course, it could be the other way around – but then you would have to resolve the Presenter, not the IView.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to register an externally hosted SQL 2000 server through Enterprise Manager which
I'm trying to register an atl service using ExeName.exe /service as described here: http://msdn.microsoft.com/en-us/library/74y2334x(VS.80).aspx
I am tying to make comments in a blog engine XSS-safe. Tried a lot
I'm trying to learn the basics of tying up unmanaged C++ and .NET. So,
In reading Haskell-related stuff I sometimes come across the expression tying the knot, I
Trying to find some simple SQL Server PIVOT examples. Most of the examples that
Trying to make a make generic select control that I can dynamically add elements
Trying to setup an SSH server on Windows Server 2003. What are some good
Trying to get my css / C# functions to look like this: body {
Trying to keep all the presentation stuff in the xhtml on this project and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.