IoC约定注册和类上的多个接口

时间:2015-01-04 08:34:17

标签: inversion-of-control ioc-container

假设我们在一个类上有多个接口

Class1: IInterface1, Interface2 {}

如果我们想依赖于使用IInterface1 / IInterface2将这些实现注入单独的类

Class Foo1(IInterface1 interface1) {}

Class Foo2(IInterface2 interface2) {}

我们将在容器中注册这两个接口

container.Register<IInterface1,Class1>();
container.Register<IInterface2,Class1>();

目前,我所做的是从类类型信息中读取接口,并将它们上的接口注册到类中。(使用反射)。这里没有约定

通常如何处理此类情况。我们可以用于这些场景的任何特定命名约定,还是通过读取类类型信息来注册接口?

0 个答案:

没有答案