views:

35

answers:

1

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,

+2  A: 

You're not registering CommandImpl as Command, you're registering it as CommandImpl.

if you do:

container.Register(Component.For<Command>().ImplementedBy<CommandImpl>());

it'll work.

I suggest you familiarize yourself with the documentation, especially installers and registration API

Krzysztof Koźmic
...yes...stupid miss...fixedit.
SharePoint Newbie