Search code examples
.netdependency-injectionkephas

Kephas has its own dependecy injection container. Why another framework, why not use an existing one?


When taking a look at Kephas framework these days, I noticed it provides its own dependency injection container. There are so many dependency injection frameworks on the market now, why bring your own implementation? Isn't that just reinventing the wheel?


Solution

  • Kephas does not provide a DI/IoC container itself, it provides only an abstraction layer over DI/IoC containers, so that it can use composition itself without being bound to a specific implementation. What it does provide is an adapter for this abstraction layer for System.Composition in the Kephas.Composition.Mef package (https://www.nuget.org/packages/Kephas.Composition.Mef/). We planned also an adapter for Autofac but we didn't have the time to implement it to end.

    Please note that this abstraction layer does come with some features unique to Kephas:

    • Registered service implementations may be overridden, to leverage layered application architectures.
    • Service contracts/interfaces drive the registration by the means of the [*AppServiceContract] attributes.

    Also note that metadata support is a required feature for DI frameworks Kephas integrate with, which, in some cases, may impose limitations. For more information you can read here: https://github.com/kephas-software/kephas/wiki/Composition-and-Dependency-Injection.