Ejemplo n.º 1
0
		/// <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));
		}
Ejemplo n.º 2
0
        /// <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));
        }
Ejemplo n.º 3
0
		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));
		}
Ejemplo n.º 4
0
        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));
        }