1

私は次のクラスを持っています:

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 は依存コマンドを待機しています」というメッセージが表示されます

私は何を間違っていますか?

ありがとう、

4

1 に答える 1

2

CommandImplとして登録しているのではなく、 としてCommand登録していCommandImplます。

もしあなたがそうするなら:

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

それはうまくいくでしょう。

ドキュメント、特にインストーラー登録 APIに慣れることをお勧めします。

于 2010-05-12T17:48:09.807 に答える