Re-bootstrapping at runtime?

Topics: Bootstrappers & IoC
Jul 18, 2011 at 3:25 PM

We are about to implement a logout feature in our Caliburn Micro application.  As the user is navigating the application, that container will have a number of objects containing information about that user.  We essentially need to be able to completely reset the runtime state of the application to ensure that nothing about the previous user can exist in the container after they log out.

What's a good practice for implementing this?

Jul 18, 2011 at 4:47 PM
Edited Jul 18, 2011 at 4:47 PM

You could perhaps create a new instance of the container, then replace and dispose the old one. As long as you delegate GetInstance,GetAllInstance,BuildUp methods in the bootstrapper to a valid container instance, CM shouldn't suffer from the replacement.
Yet, I'm not sure I like this solution very much, and I don't know if it is considered a bad practice (and why). 

I would rather expose the current user context as a property on a singleton service, from which all other components can read it.
Upon login/logout this service could notify the context change through an event, allowing dependant components to refresh or clear their state. 

Dec 22, 2011 at 5:26 PM

Hi marcoamendola,

how do i would implement that? How can i create a new instance of the container and replace it? Do you have some code sample?