Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Resurrecting the dead here but this:</p> <pre><code>........ .ExposeConfiguration(c =&gt; c.EventListeners.PreUpdateEventListeners = new IPreUpdateEventListener[] {new AuditEventListener()}); </code></pre> <p>Should be: </p> <pre><code>.ExposeConfiguration(c =&gt; c.AppendListeners(ListenerType.PreUpdate, new object[] { new AuditEventListener() }); </code></pre> <p>I believe the 'SetListener' method (described in another answer) would also remove all previous listeners. </p> <p>If you are into something a little more dynamic, you could do this:</p> <pre><code>private void AddListenerToConfiguration&lt;T&gt;(FluentConfiguration config, params ListenerType[] typesForListener) where T : class { var listener = Activator.CreateInstance&lt;T&gt;(); config.ExposeConfiguration(x =&gt; { foreach (var listenerType in typesForListener) { x.AppendListeners(listenerType, new T[] { listener }); } }); } </code></pre> <p>And then call something like this:</p> <pre><code>AddListenerToConfiguration&lt;AuditEventListener&gt;(smFactory, ListenerType.PreUpdate); </code></pre> <p>This allows for cleaner code while you are looking at the Fluent configuration. It also allows you to easily register a single type to multiple listener types.</p> <p>As for removing the default listeners, I wouldn't remove them unless I have a listener that inherits from the default listener implementation and calls base.METHODNAME on the overridden methods or replicates the same behavior as that of the default listeners.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload