Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity and Eager Singleton

Good morning, I would like to have an eager singleton in Unity, this singleton needs to be injected into so the RegisterInstance methods alone would not do it. The only other thing I can think of is in the configuration module have something like:

container.RegisterType<Singletion, Singletion>(new ContainerControlledLigetimeManager());
container.Resolve<Singletion>();

but that seams a little fudge-y to me.

like image 675
Michael Lloyd Lee mlk Avatar asked Feb 11 '26 22:02

Michael Lloyd Lee mlk


1 Answers

My best suggestion would be to implement a custom LifetimeManager class. I can't find any useful documentation on how to do this, unfortunately.

like image 60
Matt Avatar answered Feb 14 '26 19:02

Matt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!