Closed darscan closed 12 years ago
Yep, it's the requested type. I only saw the option of passing null or the requested type itself, both not making too much sense, really.
The only way to pass the targetType for getInstance would be to change that method's signature. Unfortunately, I think that that's pretty hard to understand. Implementing your own dependency provider really is something entirely different from using the injector's default API, don't you think?
On Thu, Nov 10, 2011 at 20:32, Shaun Smith reply@reply.github.com wrote:
What is provided as the targetType to apply() when getInstance() is called manually? I have a situation where I need to use getInstance() rather than an Inject point, but the provider needs the targetType. At the moment it seems to pass the requested type.
Reply to this email directly or view it on GitHub: https://github.com/tschneidereit/SwiftSuspenders/issues/61
Yeh, it's a tricky one. It cropped up while creating a provider for loggers:
There are some places where I need to pull out a fresh logger with getInstance() as the class I'm in doesn't get injected into. The only solutions I can think of are:
Expanding the getInstance signature:
getInstance(type, name="", targetType="")
or adding a new method:
getInstanceFor(type, name="", targetType="")
neither of which are terribly pretty :/
What is provided as the targetType to apply() when getInstance() is called manually? I have a situation where I need to use getInstance() rather than an Inject point, but the provider needs the targetType. At the moment it seems to pass the requested type.