[RFC] Reduce code duplication in DI