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 610769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:42:39+00:00 2026-05-13T17:42:39+00:00

I have the following items in my solution: public interface IHandle<TEvent> { void Handle(TEvent

  • 0

I have the following items in my solution:


public interface IHandle<TEvent>
{
    void Handle(TEvent event);
}

public interface IPresenter<TView>
{
}

public abstract class Presenter<TView> : IPresenter<TView>
{
    protected view;

    public TView View
    {
        set { view = value;}
    }

    // snip...
}

public interface IMyPresenter : IPresenter<IChangeRequestReviewManagementView>
{
    // snip...
}

public class MyPresenter : Presenter<MyView>, IMyPresenter, IHandle<CustomEvent>
{
    // snip...
}

And have the following registration for Windsor to register the presenters:


container.Register(AllTypes.Of(typeof(IPresenter<>))
                    .FromAssemblyNamed("Project.Presentation")
                    .WithService.Select((type, baseType) => new Type[] {GetInterfaceFromConvention(type)})
                    .Configure(config => config.LifeStyle.PerWebRequest));

private static Type GetInterfaceFromConvention(Type type)
{
    return (from found in type.GetInterfaces()
    where found.Name.Equals("I" + type.Name)
    select found).FirstOrDefault();
}

This works perfectly and I can resolve the presenters in my pages using:


public IMyPresenter Presenter
{
    set
    {
        presenter = value;
    }
}

Using this http://code.google.com/p/sneal/wiki/AspNetWindsorModule, the problem comes when I try to wire in the support for handling events supplied via a separate EventAggregator which calls implementers of IHandle<>. I added this registration:


container.Register(AllTypes.Of(typeof(IHandle<>))
                    .FromAssemblyNamed("Project.Presentation")
                    .BasedOn(typeof(IHandle<>))
                    .WithService.Base());

As this works for other areas that implement IHandle<> but after adding this the container cannot no longer resolve IMyPresenter to MyPresenter, so I must be missing something?!

  • 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-13T17:42:39+00:00Added an answer on May 13, 2026 at 5:42 pm

    Ok, I now see what the problem is (or at least I suppose I do – didn’t run the code myself).

    The problem is that you break SRP by making your MyPresenter do two jobs.

    Then, when you register your components you try to register MyPresenter twice, and the first registration wins (2nd time it won’t get registered).

    To fix this you should refactor MyPresenter to do just one thing. This will most likely require you to introduce MyPresenterHandler that will have dependency on MyPresenter to do its job.

    This way you will have no conflicting registrations and everithing should work just fine.

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

Sidebar

Related Questions

Do you have pseudocode for field validation of the following items in the UK?
I have the following shell script registered in my Login Items preferences but it
I have the following problem: I have a given number of identically formed items
I have the following XML structure: <?xml version=1.0 ?> <course xml:lang=nl> <body> <item id=787900813228567
Say I have the following: <ul> <li>First item</li> <li>Second item</li> <li>Third item</li> </ul> How
With a listbox, I have the following code to extract the item selected: private
I have a repeater that outputs divs like the following for every item returned
I have following situation: I have loged user, standard authentication with DB table $authAdapter
I have following string String str = replace :) :) with some other string;
I have following foreach-loop: using System.IO; //... if (Directory.Exists(path)) { foreach(string strFile in Directory.GetFiles(path,

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.