我有以下课程:
class Repository : IRepository
class ReadOnlyRepository : Repository
abstract class Command
abstract CommandImpl : Command
{
public CommandImpl(Repository repository){}
}
class Service
{
public Service (Command[] commands){}
}我将它们按以下代码注册:
var container = new Container("WindsorCOntainer.config");
var container = new WindsorContainer(new XmlInterpreter("WindsorConfig.xml"));
container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));
container.AddComponent("repository", typeof(RentServiceRepository));
container.Resolve<RentServiceRepository>();
container.AddComponent("command", typeof(COmmandImpl));
container.AddComponent("rentService", typeof (RentService));
container.Resolve<RentService>(); // Fails here我收到这样的信息:"RentService在等待依赖项命令“。
我做错什么了?
谢谢,
发布于 2010-05-12 17:48:09
您不是将CommandImpl注册为Command,而是将其注册为CommandImpl。
如果你这样做了:
container.Register(Component.For<Command>().ImplementedBy<CommandImpl>());会管用的。
我建议你熟悉文献资料,特别是安装工和注册API。
https://stackoverflow.com/questions/2820747
复制相似问题