1
votes

Castle Windsor is used as IoC-container. There is IPipeline interface. It is implemented by base class: PipelineBase : IPipeline. In turn it is inherited by two classes: FishPipeline : PipelineBase and OctopusPipeline : PipelineBase.

There is two customer classes, upper classes must be injected into:

First class LargeAquarium needs both FishPipeline and OctopusPipeline. And second TinyAquarium needs only FishPipeline.

How can I solve it? Is there a need to add IFishPipeline and IOctopusPipeline interfaces?

2
You should add how you got the solution as an answer rather as part of your questionMatías Fidemraizer

2 Answers

2
votes

No, as long as injected objects need to expose something that is not part of IPipeline.

1
votes

With the adoption of Matías's answer I was able to do it this way:

With given that both FishPipeline and OctopusPipeline has their own additional members to access, that are not declared in IPipeline, anyway we need two new interfaces, IOctopusPipeline one of them. Then:

IOctopusPipeline: IPipeline

PipelineBase: IPipeline

OctopusPipeline: PipelineBase, IOctopusPipeline

Then inject:

 _container.Register(Component.For<IOctopusPipeline>().ImplementedBy<OctopusPipeline>());