How can I get Castle Windsor to automatically inject a property?

后端 未结 1 1353
你的背包
你的背包 2021-02-15 16:32

I have a property on my classes for logging service.

private ILogger logger = NullLogger.Instance;
public ILogger Logger
{
    get { return logger; }
    set { l         


        
相关标签:
1条回答
  • 2021-02-15 16:56

    The lambda parameter for AddFacility is actually a creation callback (it gets called when the facility is created), not a factory.

    Use this instead:

    container.AddFacility("logging", new LoggingFacility(LoggerImplementation.Log4net, "path_to_log4net.config"));
    

    BTW Windsor automatically injects property dependencies whenever it can.

    0 讨论(0)
提交回复
热议问题