Emberfire
Dependency injection approach for object, used only in a single method
Okay, so this lazy instantiation seems like a good approach to my problem. It basically works like
IEnumerable<T>
does for collections: it injects placeholder values for the objects needed, then instantiates them the first time they are used. This seems like exactly what I need, and doesn't add obvious drawbacks. I'm going to read up on it some more to learn if it's also considered an anti-patter, bad practice or anything similar27 replies
Dependency injection approach for object, used only in a single method
This sounds like a better approach. However, I don't know how much of it can be implemented in my situation, since I'm trying to not have to rewrite the entire application during this migration
27 replies
Dependency injection approach for object, used only in a single method
Unfortunately this would result in hundreds of
ApiController
s, since the application is quite large, and that would make supporting it even more difficult than if I just used a IServiceProvider
, for example27 replies
Dependency injection approach for object, used only in a single method
I could of course separate out this controller, but as per my P.S. I feel this would just kick the can down the road, as the derived new class would still need to be instantiated somewhere
27 replies
Dependency injection approach for object, used only in a single method
P.S. One approach would be to indeed separate the method to a different object. However, doesn't that just kick the can down the road? If you would need to then inject that object to call the method, doesn't the injection still happen for the whole
TestClass
?27 replies