简体   繁体   English

一类使用依赖注入实现多个接口

[英]One class implementing multiple interfaces using dependency injection

I don't have any code with me to show you guys, but all I need to know that does Dependency Injection work in a scenario where a class implements multiple interfaces. 我没有任何代码可以向大家展示,但是我所需要知道的是,在一个类实现多个接口的情况下,依赖注入是有效的。

I do know about a single interface implemented by multiple classes using Dependency Injection. 我确实知道使用依赖注入由多个类实现的单个接口。

Yes. 是。

Why wouldn't it? 为什么不呢? As long as the class implements the interface you need you shouldn't have to care what else the class happens to implement. 只要类实现了您需要的接口,您就不必关心该类还实现了什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM