c# - StructureMap 'conditional singleton' for Lucene.Net IndexReader -
i have threadsafe object expensive create , needs available through application (a lucene.net indexreader).
the object can become invalid, @ point need recreate (indexreader.iscurrent false, need new instance using indexreader.reopen).
i'd able use ioc container (structuremap) manage creation of object, can't work out if scenario possible. feels kind of "conditional singleton" lifecycle.
does structuremap provide such feature? alternative suggestions?
i use scope of perrequest
, not return indexreader
directly. instead, i'd return abstraction of indexreader
perform check on static reference held on class level.
then, when property on shim/proxy/abstraction accessed, check static reference (you make thread-safe, of course) , re-get indexreader
if needed before delivering user.
Comments
Post a Comment