Closed schuettecarsten closed 2 years ago
Hi @schuettecarsten, thanks for reaching out! This is a bit bigger request and I need some time to think about the possible solutions. I can't promise anything for now, just that I'll think about it.
Hi @schuettecarsten,
I published a new pre-release version that contains the proposed solution for this issue. The IRequestContext
which is accessible in factory delegates got a new method ExcludeFromTracking(instance)
. Passing your cached instance will exclude it from disposing.
Please let me know your thoughts!
Thank you, as I compile Stashbox myself at the moment, the prereleased version is based on the current dev branch?
Yes, it was published from the current dev
branch.
This issue is marked stale because it has been open for 90 days with no activity.
This issue was closed due to no activity.
I use factory methods to create instances of some types and also return "cached" instances if they are valid for the current program state. It would be great if it is possible to tell Stashbox from a factory methods that the currently returned instance should not be added ot the scope (overwrite to Transient) or should not be dispose-tracked, because it might be cached somewhere. Currently, it is only possible to disable disposal tracking for the whole registration, but not decide this per returned instance from the factory method.
I know that this is a very special enhancement.... :-)