Reduce code duplication in DI to maximum.