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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:28:44+00:00 2026-05-27T17:28:44+00:00

I have following component composition: public interface IJob { ILogger Logger { get; set;

  • 0

I have following component composition:

public interface IJob {
    ILogger Logger { get; set; }
}

public class JobC : IJob
{
    public ILogger Logger { get; set; }
    private ServiceA serviceA;
    private ServiceB serviceB;

    public JobC(ServiceA serviceA, ServiceB serviceB)
    {
        this.serviceA = serviceA;
        this.serviceB = serviceB;
    }
}

public class ServiceB
{
    public ILogger Logger { get; set; }
}

public class ServiceA
{
    public ILogger Logger { get; set; }
}

As you can see, there’s Logger property all around. Thing is, that I need to pass that property value during resolving (different jobs are requiring different configuration loggers).
So if only top component would need this, it would be as simple as

var childLogger = Logger.CreateChildLogger(jobGroupName);
var job = windsorContainer.Resolve(jobType);
job.Logger = childLogger;

But I need to pass childLogger down the tree and that tree is quite complex, I don’t wish to manually pass logger instance to each component, which needs it, wondering if Windsor could help me at this?

Update: May be this will help better understand problem:
In wiki there’s notice:

Inline dependencies don’t get propagated
Whatever arguments you pass to Resolve method will only be available to the root component
you’re trying to resolve, and its Interceptors. All the components further down (root’s
dependencies, and their dependencies and so on) will not have access to them.

Why is it like so and is there any workaround?

Update 2:
May be it will help, if I’ll add real situation.

So, we have Application, which sends/receives data from/to various sales channels. Each sales channel has corresponding collection of jobs, like send updated product information, receive orders, etc (each job may contain smaller jobs inside). So it is logical, that we need to keep each channel’s log information separate from other channel’s, but single channel’s jobs logs should go to single listener, that we could see sequence of what is happening (if each job and subjob would have own logging listener, we would need to merge logs by time to understand what is going on). Some channels and their job sets are not known at compile time (let’s say there’s channel A, we can start separate channel for a specific country by simple adding that country to DB, depending on load we can switch synchronization method, etc.).

What all that means, that we may have UpdateProductsForChannelAJob, which will be used in two different channels (ChannelA US and ChannelA UK), so it’s logger will depend on which channel it depends to.

So what we are doing now, is we create child logger for each channel and we pass it when resolving Job instance as a parameter. That works, but has one annoying thing – we have to pass logger instance manually inside job to each dependency (and dependencies dependency), that may be logging something.

Update 3:

I’ve found in Windsor documentation feature, that sounds like what I need:

There are times where you need to supply a dependency, which will not be known until the creation time of the component. For example, say you need a creation timestamp for your service. You know how to obtain it at the time of registration, but you don’t know what its specific value will be (and indeed it will be different each time you create a new instance). In this scenarios you use DynamicParameters method.

And you get two parameters in DynamicParameters delegate, one of them is dictionary and

It is that dictionary that you can now populate with dependencies which will be passed further to the resolution pipeline

Given that, I thought this will work:

public interface IService
{
}

public class ServiceWithLogger : IService
{
    public ILogger Logger { get; set; }
}

public class ServiceComposition
{
    public ILogger Logger { get; set; }

    public IService Service { get; set; }

    public ServiceComposition(IService service)
    {
        Service = service;
    }
} 

public class NameService
{
    public NameService(string name)
    {
        Name = name;
    }
    public string Name { get; set; }
}

public class NameServiceConsumer
{       
    public NameService NameService { get; set; }
}

public class NameServiceConsumerComposition
{       
    public NameService NameService { get; set; }
    public NameServiceConsumer NameServiceConsumer { get; set; }
}

[TestFixture]
public class Tests
{
    [Test]
    public void GivenDynamicParamtersConfigurationContainerShouldPassLoggerDownTheTree()
    {
        var container = new WindsorContainer();
        container.AddFacility<LoggingFacility>();
        container.Register(
            Component.For<IService>().ImplementedBy<ServiceWithLogger>().LifestyleTransient(),
            Component.For<ServiceComposition>().DynamicParameters((k, d) =>
            {
                d["Logger"] = k.Resolve<ILogger>().CreateChildLogger(d["name"].ToString());
            }).LifestyleTransient()
            );

        var service = container.Resolve<ServiceComposition>(new { name = "my child" });
        var childLogger = ((ServiceWithLogger) service.Service).Logger;
        Assert.IsTrue(((ConsoleLogger)childLogger).Name.Contains("my child"));
    }

    [Test]
    public void GivenDynamicParamtersConfigurationContainerShouldPassNameDownTheTree()
    {
        var container = new WindsorContainer();
        container.AddFacility<LoggingFacility>();
        container.Register(
            Component.For<NameService>().LifestyleTransient().DependsOn(new {name = "default"}),
            Component.For<NameServiceConsumer>().LifestyleTransient(),
            Component.For<NameServiceConsumerComposition>().DynamicParameters((k, d) =>
            {
                d["nameService"] = k.Resolve<NameService>(d["nameParam"]);
            }).LifestyleTransient()
            );

        var service = container.Resolve<NameServiceConsumerComposition>(new { nameParam = "my child" });
        Console.WriteLine(service.NameServiceConsumer.NameService.Name);
        Assert.IsTrue(service.NameServiceConsumer.NameService.Name.Contains("my child"));
    }
}

But it does not.

  • 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-27T17:28:45+00:00Added an answer on May 27, 2026 at 5:28 pm

    I think I finally got the aha moment why this is relatively easy to implement, but is not implemented in Windsor (and I think any other container).
    Let’s say we have following configuration:

    public class TransientA
    {
        public SingletonC SingletonC { get; set; }
        public ILogger Logger { get; set; }
    }
    
    public class TransientB
    {
        public SingletonC SingletonC { get; set; }
        public ILogger Logger { get; set; }
    }
    
    public class SingletonC
    {
        public ILogger Logger { get; set; }
    }
    

    class names reflect their lifestyles, so if you would do recursive property injection on Resolve for TransientA, you would change TransientB.SingletonC.Logger property also!

    You could skip singletons property injection on propagation, but that a) would add confusion b) would not solve initial problem anyway (some of the logging would go to singlenton’s logger).

    So in case to use recursive property injection you would need to add limitation, that component should not have singleton dependencies (PerWebRequest/PerThread also) in it’s dependency hierarchy, which is quite limiting.

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

Sidebar

Related Questions

We have the following shared component: public class OurServiceBase : System.ServiceProcess.ServiceBase This class has
I have the following script transformation component. public class ScriptMain : UserComponent { Regex
I have a Service class such as following: @Transactional @Component(value = userServiceImpl) public class
I have following situation: public interface IFormater { StyleInformation GetStyleInformation(Fact fact); FactType[] Formats {
I have the following: class Series < ActiveRecord::Base has_many :components end class Component <
Is there a way to have following ? CLASS ucComponent.ascx Component.cs and then within
I have the following code: [SuppressMessage( Microsoft.Performance, CA1800:DoNotCastUnnecessarily )] private static void SetTestConnectionString( Component
I have a component called a TableDataViewer that contains the following pieces of data
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have the following component mapping in Windsor xml: <component id=dataSession.DbConnection service=System.Data.IDbConnection, System.Data, Version=2.0.0.0,

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.