title: Named singleton instance in StructureMap with multiple nHibernate Session factories (StructureMap 2.5.4)
body: <p>I have the exact identical scenario as described in <a href="https://stackoverflow.com/questions/5196082/named-singleton-instance-in-structuremap-multiple-nhibernate-session-factories">Named singleton instance in StructureMap (Multiple nHibernate session factories)</a></p>
  
  <p>If I implement this using StructureMap 2.6.2 - great!</p>
  
  <p>However, I have to currently use StructureMap 2.5.4 due to various factors involved in legacy projects not being able to use up-to-date .NET framework versions as well as a few other reasons. Assume for this question that I cannot upgrade for the forseeable future.</p>
  
  <p>2.5.4 is obviously quite different in syntax to 2.6.2 and I can't work out how to implement the same thing using it's API.</p>
  
  <p>In particular, it's this stuff</p>
  
  <pre><code>For&lt;ISessionFactory&gt;().LifecycleIs(Lifecycles.GetLifecycle(InstanceScope.Singleton))
              .Add(context =&gt; CreateSessionFactory(@"MyName")).Named("MySessionFactory");
          For&lt;ISession&gt;().LifecycleIs(Lifecycles.GetLifecycle(InstanceScope.Hybrid))
              .Add(context =&gt; context.GetInstance&lt;ISessionFactory&gt;("MySessionFactory").OpenSession()).Named("MyName");
  
  For&lt;ISessionFactory&gt;().LifecycleIs(Lifecycles.GetLifecycle(InstanceScope.Singleton))
              .Add(context =&gt; CreateSessionFactory(@"My2ndName")).Named("My2ndSessionFactory");
          For&lt;ISession&gt;().LifecycleIs(Lifecycles.GetLifecycle(InstanceScope.Hybrid))
              .Add(context =&gt; context.GetInstance&lt;ISessionFactory&gt;("MySessionFactory").OpenSession()).Named("My2ndName");
  </code></pre>
  
  <p>...with a method called CreateSessionFactory(string) that creates the relevant configuration.</p>
  
  <p>The "Add" and subsequent "GetInstance" are invalid and need to be refactored to work with 2.5.4 - I'm just too dumb to work out how, or if indeed you can achieve the same thing.</p>
  
  <p>Cheers</p>