python-dependency-injector icon indicating copy to clipboard operation
python-dependency-injector copied to clipboard

Injection of a dynamic class

Open GuySuday opened this issue 2 years ago • 0 comments

Given a class known at runtime (dynamic) with dependencies in the c'tor, can we use the container to initialize such class?

I saw the guide of dynamic containers, but it requires to know the dynamic class' dependencies before runtime.

Following the example from the guide: Let's assume both UserService and AuthService have dependencies in their c'tors, and of of the dependencies are from a (static) known set of values. How would we instantiate the classes given we don't know the classes beforehand (and especially not their dependencies), because they are known only at runtime (from a condif file e.g)?

Thank you for your help :)

GuySuday avatar May 07 '22 06:05 GuySuday