Resurrecting the dead here but this:
........
.ExposeConfiguration(c => c.EventListeners.PreUpdateEventListeners = new IPreUpdateEventListener[] {new AuditEventListener()});
Should be:
.ExposeConfiguration(c => c.AppendListeners(ListenerType.PreUpdate, new object[]
{
new AuditEventListener()
});
I believe the 'SetListener' method (described in another answer) would also remove all previous listeners.
If you are into something a little more dynamic, you could do this:
private void AddListenerToConfiguration<T>(FluentConfiguration config, params ListenerType[] typesForListener)
where T : class
{
var listener = Activator.CreateInstance<T>();
config.ExposeConfiguration(x =>
{
foreach (var listenerType in typesForListener)
{
x.AppendListeners(listenerType, new T[]
{
listener
});
}
});
}
And then call something like this:
AddListenerToConfiguration<AuditEventListener>(smFactory,
ListenerType.PreUpdate);
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.
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.