Reduce code duplication between DI extensions