StructureMap 'conditional singleton' for Lucene.Net IndexReader

Posted by Gareth D on Stack Overflow See other posts from Stack Overflow or by Gareth D
Published on 2011-02-09T17:53:49Z Indexed on 2011/02/26 7:24 UTC
Read the original article Hit count: 203

I have a threadsafe object that is expensive to create and needs to be available through my application (a Lucene.Net IndexReader).

The object can become invalid, at which point I need to recreate it (IndexReader.IsCurrent is false, need a new instance using IndexReader.Reopen).

I'd like to able to use an IoC container (StructureMap) to manage the creation of the object, but I can't work out if this scenario is possible. It feels like some kind of "conditional singleton" lifecycle.

Does StructureMap provide such a feature? Any alternative suggestions?

© Stack Overflow or respective owner

Related posts about c#

Related posts about singleton