开发者

StructureMap reset singleton instance

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜