您好,已将以下组件注册到 Castle Windsor:
public class CommandDispatcher : IServiceCommandDispatcher
{
private readonly IWindsorContainer container;
public CommandDispatcher(IWindsorContainer container)
{
this.container = container;
}
#region IServiceCommandDispatcher Members
public void Dispatch<TCommand>(TCommand command) where TCommand : IServiceCommand
{
var handler = container.Resolve<IServiceCommandHandler<TCommand>>();
handler.Handle(command);
}
#endregion
}
并且 dispatcher 的注册方式如下:
Component
.For<IServiceCommandDispatcher>()
.ImplementedBy<CommandDispatcher>(),
但是当我解析调度程序的实例时,字段容器为空。我应该怎么做才能将容器传递给已解决的子项?