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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:32:46+00:00 2026-05-23T18:32:46+00:00

I have a decorator and actual implementation that looks like this: public interface IAmUsedTwice

  • 0

I have a decorator and actual implementation that looks like this:

public interface IAmUsedTwice
{
    void DoSomething();
}

public class ForReal: IAmUsedTwice
{
    public SomethingElse Need { get; set; }

    public ForReal(SomethingElse iNeed)
    {
        Need = iNeed;
    }

    public void DoSomething()
    {
        Console.WriteLine("Realing doing something here");
    }
}

public class SomethingElse {}

public class DecoratingIsFun: IAmUsedTwice
{
    private IAmUsedTwice Actual { get; set; }

    public DecoratingIsFun(IAmUsedTwice actual)
    {
        Actual = actual;
    }

    public void DoSomething()
    {
        Console.WriteLine("This is a decorator!");
        Actual.DoSomething();
    }
}

and the configuration was set up before I started this using xml for the actual implementation and looks something like this:

<component id="forReal"
           service="SomeNamespace.IAmUsedTwice, SomeNamespace"
           type="SomeNamespace.ForReal, SomeNamespace">
  <parameters>
    <iNeed>${iNeed}</iNeed>        
  </parameters>
</component>

and you can assume that the iNeed component is set up correctly already.

Now, the system is already configured to use the ForReal class, but what I want to do is swap out the ForReal class and use the DecoratingIsFun class now.

I created an installer to register the DecoratingIsFun class like so:

public class DecoratorInstaller: IWindsorInstaller
{
    public void Install(IWindsorContainer container, IConfigurationStore store)
    {
        container.Register(
            Component.For<IAmUsedTwice>()
                .ImplementedBy<DecoratingIsFun>()
        );
    }
}

However, I still need to tell it two things.

  1. When it resolves IAmUsedTwice I want it to resolve an instance of DecoratingIsFun from now on instead of the other class
  2. When resolving DecoratingIsFun I need it to resolve ForReal as a constructor argument for the instance it’s creating.

The goal will be that I can then call windsorContainer.Resolve() and get a DecoratingIsFun instance.

How can I tell the installer to do that?

  • 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-23T18:32:46+00:00Added an answer on May 23, 2026 at 6:32 pm

    In order to allow DecoratingIsFun to decorate ForReal, you need to ensure that DecoratingIsFun is registered before ForReal – then Windsor will correctly resolve the decorator and satisfy its dependency with the next registration of something that implements IAmUsedTwice.

    But since you’re using XML to register the first service, I don’t know how to achieve that, since the XML is sucked up when you instantiate WindsorContainer.

    But why are you using XML in the first place? Is it because you don’t think that you can use XML to configure components unless you’re also using it to register them?

    If that is the case, you should reduce the XML to something like this:

    <component id="forReal">
        <parameters>
            <iNeed>${iNeed}</iNeed>        
        </parameters>
    </component>
    

    and move the registration to your code, allowing you to control the order of registration. Then, make sure that ForReal is registered with .Named("forReal"), allowing the configuration to be matched when the instance is resolved.

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

Sidebar

Related Questions

I have a decorator chain that looks like this when initially created: IType calculator
I have a decorator like this: def region_required(view_func): def new_view(request, ctx = {}, *args,
I have a decorator-like pattern with a base that requires a constructor parameter. The
Assuming I have a decorator and a wrapped function like this: def squared(method): def
I have been using this excellent decorator for memoization, which I found on the
I have added checkbox in display table using decorator class as shown in below
I have a decorator that currently requires each function that uses it to have
I have this decorator, used to decorate a django view when I do not
I have a decorator like below. def myDecorator(test_func): return callSomeWrapper(test_func) def callSomeWrapper(test_func): return test_func
I have a Decorator Control class which I want to collect all the validation

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.