hadashiA / VContainer

The extra fast, minimum code size, GC-free DI (Dependency Injection) library running on Unity Game Engine.
https://vcontainer.hadashikick.jp
MIT License
1.89k stars 165 forks source link

Added option to TryGetSharedInstance to IObjectResolver #573

Closed AlonTalmi closed 5 months ago

AlonTalmi commented 10 months ago

Added to IObjectResolver interface a TryGetSharedInstance which only returns if a shared instance of the request type (or Registration) exists and was created.

Can be used to update instances of a type (if they're not transient) at runtime without resolving them needlessly.

I also added generic extension methods and Unit Tests

vercel[bot] commented 10 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
vcontainer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2023 10:20am
hadashiA commented 5 months ago

The use case may not be very clear. Also, I am reluctant to function in a way that could abuse DI. Please let me reject this time. Thanks for your suggestion.