Castle Windsor: How do I inject all implementations of interface into a ctor?

前端 未结 4 2225
臣服心动
臣服心动 2020-12-28 14:59

I\'ve written an interface which is implemented by multiple classes. I want to write a Service class which will have all the registered implementations injected into its cto

4条回答
  •  没有蜡笔的小新
    2020-12-28 15:13

    Found this answer useful though I was still missing how to register all the implementations of a given interface.

    Hope this helps!

    container.Register(
                Classes.FromAssemblyContaining()
                    .BasedOn().WithService.FromInterface()
                );
    

提交回复
热议问题