How do I set up Array/List dependencies in code with Castle Windsor?
Posted
by SharePoint Newbie
on Stack Overflow
See other posts from Stack Overflow
or by SharePoint Newbie
Published on 2010-05-12T16:22:29Z
Indexed on
2010/05/13
8:04 UTC
Read the original article
Hit count: 205
Hi,
I have the following classes:
class Repository : IRepository
class ReadOnlyRepository : Repository
abstract class Command
abstract CommandImpl : Command
{
public CommandImpl(Repository repository){}
}
class Service
{
public Service (Command[] commands){}
}
I register them in code as follows:
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
I get the message that "RentService is waiting for dependency commands"
What am I doing wrong?
Thanks,
© Stack Overflow or respective owner