[DependencyInjection] Added feature which allows to use closure as a factory method