I have some bindings that are setup as singletons. I want them to always return the same instance until a certain point at which I want all the singleton instances to be cleared. I don't want to remove and re-add the bindings, just clear out the instances that have been created. Is this possible?
A:
Singletons are only single per kernel. You could just create a new kernel.
Alternatively, it seems that you don't really want singletons. How about using a class that contains the references you need.
Ray
2009-07-08 18:59:16
Currently I am just creating a new kernel. I do want a singleton because I want everywhere the type is injected to be the same object. there is a point when I want it cleared though.What I'm doing is setting up NHibernate with WCF and I want an ISession PerCall. I could reuse the kernel because the config doesn't change at all, but on every call I want the instances to be reset. So for now I'm creating a new kernel on every call, but I could just keep the kernel around if there was a way to clear out the instances.
Josh Close
2009-07-09 14:59:34