title: NHibernate event listeners
body: <p>I'm trying to add an implementation of IPostLoadEventListener to my NHibernate configuration using FluentNHibernate. I can do so as illustrated here:</p>
  
  <p><a href="https://stackoverflow.com/questions/1433638/how-to-add-event-listener-via-fluent-nhibernate">how to add event listener via fluent nhibernate?</a></p>
  
  <p>However, creating a new array to replace the old one completely discards any existing event listeners. I can get around that like so:</p>
  
  <pre><code>return Fluently.Configure()
      .Database(config)
      .Mappings(m =&gt; m.AutoMappings.Add(mappings))
      .ExposeConfiguration(cfg =&gt;
          {
              cfg.EventListeners.PostLoadEventListeners =
                  new IPostLoadEventListener[] { 
                      new UtcDateEventListener(),
                      new DefaultPostLoadEventListener() // &lt;&lt;&lt; this one is the default
                  };
              cfg.EventListeners.SaveOrUpdateEventListeners =
                  new ISaveOrUpdateEventListener[] { 
                      new UtcDateEventListener(),
                      new DefaultSaveOrUpdateEventListener() // &lt;&lt;&lt; this one is the default
                  };
          })
      .BuildConfiguration()
      .BuildSessionFactory();
  </code></pre>
  
  <p>But I only know about the default event listeners by stepping through the code to determine what I was overwriting. I'd like to add my event listener without overwriting any existing event listeners, but doing so like I've shown above seems very smelly, to me. The existing event listeners are exposed as an array (rather than a collection or a list, which would make more sense). Is there a cleaner way to handle this?</p>