title: Registering fluent nhibernate mappings for all assemblies in an application
body: <p>Starting with some code:</p>
  
  <pre><code>sessionFactory = Fluently.Configure(cfg)
                  .Mappings(m =&gt; 
                  {
                      List&lt;Assembly&gt; allAssemblies = new List&lt;Assembly&gt;();
                      string path = Assembly.GetExecutingAssembly().Location;
                      foreach (string dll in Directory.GetFiles(path, "*.dll"))
                      {
                          m.FluentMappings.AddFromAssembly(Assembly.LoadFile(dll));
                      }
                  })
                  .BuildSessionFactory();
  </code></pre>
  
  <p>I'm very new to both nhibernate and fluent nhibernate. The bit of code above looks like it should work, but to me it looks really ugly. Is there a neater way?</p>
  
  <p>One problem I have is that the code that calls the above code is in a core assembly and is unable to make reference to some of the assemblies that need mapping as their assemblies reference the core assembly. So I can't just use a few calls to <code>AddFromAssemblyOf&lt;T&gt;</code>.</p>
  
  <p>Is there a cleaner way to do this?</p>