2010-05-12 2 views
1

나는 다음과 같은 클래스가 다음과 같이 코드에서 내가 그들을 등록Castle Windsor의 코드에서 Array/List 종속성을 설정하려면 어떻게합니까?

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 종속성 명령을 기다리고 있습니다"라는 메시지가 내가 잘못하고있어?

감사합니다, 당신은 CommandCommandImpl를 등록하지 않을

답변

2

, 당신은 CommandImpl로 등록하고 있습니다.

당신이 할 경우 : 작동합니다

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

.

나는 당신이 ..., the documentation와 fixedit을 특히 installersregistration API

+0

... 그래 ... 바보 미스를 숙지하는 것이 좋습니다. –

관련 문제