/// <summary> /// Examines the channel network and identifies any audit event consumers and connects /// the appropriate event listeners to the NHibernate configuration so that events are /// sent from NHibernate to the channel network /// </summary> /// <param name="cfg">The NHibernate configuration being modified</param> /// <param name="channel">The channel containing the audit event listeners</param> public static void AddAuditEventListeners(this Configuration cfg, UntypedChannel channel) { var configurators = new EventListenerConfigurator[] { new PreInsertEventConfigurator(), new PostInsertEventConfigurator(), new PreUpdateEventConfigurator(), new PostUpdateEventConfigurator(), }; var visitor = new AuditEventConsumerChannelVisitor(configurators); visitor.Configure(channel); configurators.Each(x => x.ApplyTo(cfg, channel)); }
public void Should_return_the_event_types_for_the_configuration() { var network = new ChannelAdapter(); network.Connect(x => { x.AddConsumerOf<PostUpdateEvent<TestInstance>>() .UsingConsumer(msg => { }); }); var configurator = new PostUpdateEventConfigurator(); var visitor = new AuditEventConsumerChannelVisitor(new EventListenerConfigurator[] { configurator, }); visitor.Configure(network); configurator.Types.Count().ShouldEqual(1); configurator.Types.First().ShouldEqual(typeof(TestInstance)); }
public void Should_return_the_event_types_for_the_configuration() { var network = new ChannelAdapter(); network.Connect(x => { x.AddConsumerOf <PostUpdateEvent <TestInstance> >() .UsingConsumer(msg => { }); }); var configurator = new PostUpdateEventConfigurator(); var visitor = new AuditEventConsumerChannelVisitor(new EventListenerConfigurator[] { configurator, }); visitor.Configure(network); configurator.Types.Count().ShouldEqual(1); configurator.Types.First().ShouldEqual(typeof(TestInstance)); }