使用Windsor容器设置静态属性依赖需要什么配置?
我现在有下面的类,我希望Logger属性被注入。
static class StuffDooer { static ILogger Logger { get; set; } static StuffDooer() { Logger = NullLogger.Instance; } }
<facility id="logging" type="Castle.Facilities.Logging.LoggingFacility, Castle.Facilities.Logging" loggingApi="nlog" customLoggerFactory="Castle.Services.Logging.NLogIntegration.NLogFactory" configFile="Configuration/nlog.config" />
StuffDooer.Logger = container.Resolve<ILoggerFactory>().GetLogger(typeof(StuffDoer));
如果你觉得这很难看,那是正确的反应。静力学和国际奥委会不能混为一谈,就像酒精和驾驶一样。