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 AsNoneLazy ContainerBuilder extension #574

Closed AlonTalmi closed 8 months ago

AlonTalmi commented 10 months ago

I added a simple extension method that registers a build callback that resolves the type requested.

Unlike Zenject and other similar DI libraries where NoneLazy is marked during the registration phase here it's controlled in the container level. I personally like it, but can see why you might not.

Anyway, I also added a Unit Test.

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 11:16am
hadashiA commented 8 months ago

Thank you. Probably useful.

However, I don't think the name NonLazy is very clear.

If it is not resolved from anywhere and an Instance is created, it is nothing more than an entry point in the broadest sense. So I have only allowed APIs that specifically specify the type of entry point, such as RegisterEntryPoint or RegisterComponent.

Maybe it's the same with ASP . NET Core, for example AddControllers, AddHostedService, etc. I prefer that approach.