krisdyson
krisdyson

Reputation: 3255

StructureMap reset singleton instance

I have created a bootstrapper 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

Upvotes: 3

Views: 1100

Answers (1)

Brook
Brook

Reputation: 6019

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.

Upvotes: 1

Related Questions