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

  • SEARCH
  • Home
  • 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

Using Castle Windsor I can register multiple implementations of a type e.g. container.Register(Component.For<IMyInterceptor>() .ImplementedBy<MyInterceptor>();
We have an old asp.net application that has no unit tests, integration tests, component
I m trying to create a new register and login page. I have a
If I register a component with the container with a name (don't worry... contrived
I am trying to register all classes that implement my IProcess<T1, T2> interface with
I am trying to create a page that lets a user delete an image
Basicly I can register one service like this. Container.Register(Component.For<IMyService>() .AsWcfClient(new DefaultClientModel() { Endpoint =
This is how my Application_Start looks: protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); _container.Register(Component.For<IWindsorContainer>()
I am trying to register the following class using the fluent interface: public class
I'm currently trying to register a JS function call from a .NET page which

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.