Search code examples
dependency-injectioninversion-of-controlkephas

Am I forced into using the attributed service registration in Kephas?


The attributed service registration in Kephas is a nice feature, but am I forced into using it? I mean, because Kephas provides only an abstraction layer over the actual DI/IoC implementation, it cannot provide all the features specific DI containers may offer.

Besides, my team may have constraints regarding the coding style to follow and/or there is already a large code base to support.


Solution

  • No, you are not forced at all. You can bring your own container, register services as you like, but if you want Kephas to play together with your container its services must be registered there, too. It does this using the attributed model ([*AppServiceContract] and [OverridePriority/ProcessingPriority] attributes), so you have to support them too, and this in the IoC adapter. As I clarified in another answer, if you are not satisfied with the System.Composition adapter or you need an adapter for another DI framework, you can just write your own.