mardi 24 novembre 2020

C# DI Lifetime Management golden rule about what can contain what

So, basically I got very confused recently (I worked whit DI three years ago). I know that there used to exist some kind of rule like:

A Transient object cannot be injected into a Singleton/Scoped
or
A Scoped object cannot be injected into a Transient

But I do not found anything related anymore, so I'm not sure what is safe and what is not safe.

For example is it ok to inject via constructor a Scoped object into a Singleton object and vice-versa?




Aucun commentaire:

Enregistrer un commentaire