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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:29:10+00:00 2026-05-16T18:29:10+00:00

I have a problem that I can’t seem to resolve. I’m sure it’s simple,

  • 0

I have a problem that I can’t seem to resolve. I’m sure it’s simple, but I honestly cannot figure it out. I have a simple type that I reuse on multiple controllers. The problem that I’m faced with is that it’s the SAME type with different configurations. I need different instances of this type to be used on different controllers. I’ve dumbed it down as simple as I can think to try and explain it…

Consider the following:

interface ISimpleType 
{ 
    string Value { get; } 
}

class ConcreteType : ISimpleType 
{
    private readonly string _value;

    public ConcreteType(string value) 
    { 
        _value = value; 
    } 

    public string Value { get { return _value; } }

}

In my web.config, I’ve defined two instances of the same type with their own id’s:

<component id="concrete.one" 
    service="MyApp.ISimpleType, MyApp" 
    type="MyApp.ConcreteType, MyApp">
  <parameters>
    <value>ONE</value>
  </parameters>
</component>

<component id="concrete.two" 
    service="MyApp.ISimpleType, MyApp" 
    type="MyApp.ConcreteType, MyApp">
  <parameters>
    <value>TWO</value>
  </parameters>
</component>

Now on my MVC controller, I want to be able to accept an ISimpleType interface as the parameter, but have it use the correct ConcreteType instance depending on the parameter name:

public class FirstController : BaseController 
{ 
    public FirstController(ISimpleType firstType) : base(firstType) { ... }
}

public class SecondController : BaseController 
{
    public SecondController(ISimpleType secondType) : base(secondType) { ... }
}

I’d like to register all instances of ISimpleType named “firstType” to use the Windsor component “concrete.one”, and all ISimpleTypes named “secondType” to use the Windsor component “concrete.two”.

The only alternative that I can see is to NOT pass this as a parameter and simply initialize it in the constructor manually.

public FirstController()
{
    base.SimpleType = WindsorServiceFactory.Create<ISimpleType>("concrete.one");
}

Is there a better way?

Thanks in advance!

  • 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-16T18:29:11+00:00Added an answer on May 16, 2026 at 6:29 pm

    This is easily done via service overrides.

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

Sidebar

Related Questions

I have a problem that I can't seem to figure out. I'm trying to
I have a weird problem that i can't figure out a solution for: I've
I have a problem with Lucene's scoring function that I can't figure out. So
I have a problem that I can't figure out what to do next. I
So I have a problem that I can not figure out. I am writing
I have a problem that I can't figure out myself. I've tried using LEFT
I have a problem that I can't figure out. I'm building a small framework
I have a jQuery problem that I can't seem to work out on my
I have a strange problem that I can't figure out when trying to do
I have a little problem that I can't figure out how to solve. I

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.