views:

51

answers:

1

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.

+1  A: 

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

Matt
Thanks. I've looked into this and could not work out how, I think it not doable even then. I ended up creating a custom LifetimeManager (extending ContainerControlledLigetimeManager) and a helper class. The helper class looped through all the registered classes and resloved any with that lifetime manager.
mlk