I have created a bootst开发者_JAVA技巧rapper which creates a singleton object. Under some circumstances, I wish to have the singleton recreated... I have tried: ObjectFactory.Model.For().EjectAndRemoveAll();
Does anyone know how I can remove current instances for a specific type, without removing the rules that govern its creation. e.g. ObjectFactory.EjectAllInstancesOf will remove the config rules as well.
thanks for your help
One way would be to define a lifecycle by overriding ILifeCycle which ejects the cached instance when your conditions are met.
You could start by looking at the implementation of the singleton lifecycle in the structuremap source and perhaps inherit or modify that.
精彩评论