Yes, agreed, it's very specific to my problem, and a solution probably
wouldn't be useful in many other scenarios.
For example, the Presenter pattern wouldn't have this problem, as any
view component that leaves the stage, and has no other references,
would get GC'd - in turn freeing it's Presenter.
With the Mediator pattern however, a view component doesn't have a
reference to it's Mediator. Instead, the Mediator has a reference to
it's view, and the view is kept blissfully unaware it's Mediator (and
the rest of the application).
Ideally, the Mediator should only be kept alive by a reference in an
external Dictionary that uses the Mediator's View component as a weak
key. Then, when the view component leaves the stage (again, assuming
there are no other refs to it), it will get GC'd, and due to it being
a weak key in the Dictionary, the Mediator will get freed as well.
But: the Mediator still has a ref to the view (the one that was
injected), keeping the view key in the Dictionary, and in turn keeping
the Mediator alive. I have to null the Mediators ref to the view to
let the GC do it's thing.
Anyhow, I'm sure I can solve it pretty easily with the SmartyPants
Reflection util. I just thought that nulling all dependencies might be
useful outside of my problem, but perhaps not so much!
Cheers!
On Apr 19, 10:12 am, Josh McDonald <
j...@joshmcdonald.info> wrote:
> To be honest, I just can't see any use for "uninjecting" something that
> couldn't be be better done with clever use of live injections. What exactly
> are you trying to achieve?
>
> 2009/4/19 darscan <
Dars...@gmail.com>