Esempio n. 1
0
        public void TransferToBus(IAdvancedBus advancedBus)
        {
            var rebusEvents = advancedBus.Events;

            if (MessageSent != null)
            {
                foreach (var listener in MessageSent.GetInvocationList().Cast <MessageSentEventHandler>())
                {
                    rebusEvents.MessageSent += listener;
                }
            }

            if (BeforeMessage != null)
            {
                foreach (var listener in BeforeMessage.GetInvocationList().Cast <BeforeMessageEventHandler>())
                {
                    rebusEvents.BeforeMessage += listener;
                }
            }

            if (AfterMessage != null)
            {
                foreach (var listener in AfterMessage.GetInvocationList().Cast <AfterMessageEventHandler>())
                {
                    rebusEvents.AfterMessage += listener;
                }
            }

            if (BeforeTransportMessage != null)
            {
                foreach (var listener in BeforeTransportMessage.GetInvocationList().Cast <BeforeTransportMessageEventHandler>())
                {
                    rebusEvents.BeforeTransportMessage += listener;
                }
            }

            if (AfterTransportMessage != null)
            {
                foreach (var listener in AfterTransportMessage.GetInvocationList().Cast <AfterTransportMessageEventHandler>())
                {
                    rebusEvents.AfterTransportMessage += listener;
                }
            }

            if (PoisonMessage != null)
            {
                foreach (var listener in PoisonMessage.GetInvocationList().Cast <PoisonMessageEventHandler>())
                {
                    rebusEvents.PoisonMessage += listener;
                }
            }
        }
Esempio n. 2
0
        internal void TransferToBus(IBus bus)
        {
            var rebusEvents = bus.Advanced.Events;

            if (MessageContextEstablished != null)
            {
                foreach (var listener in MessageContextEstablished.GetInvocationList().Cast <MessageContextEstablishedEventHandler>())
                {
                    rebusEvents.MessageContextEstablished += listener;
                }
            }

            if (MessageSent != null)
            {
                foreach (var listener in MessageSent.GetInvocationList().Cast <MessageSentEventHandler>())
                {
                    rebusEvents.MessageSent += listener;
                }
            }

            if (BeforeInternalSend != null)
            {
                foreach (var listener in BeforeInternalSend.GetInvocationList().Cast <BeforeInternalSendEventHandler>())
                {
                    rebusEvents.BeforeInternalSend += listener;
                }
            }

            if (BeforeMessage != null)
            {
                foreach (var listener in BeforeMessage.GetInvocationList().Cast <BeforeMessageEventHandler>())
                {
                    rebusEvents.BeforeMessage += listener;
                }
            }

            if (AfterMessage != null)
            {
                foreach (var listener in AfterMessage.GetInvocationList().Cast <AfterMessageEventHandler>())
                {
                    rebusEvents.AfterMessage += listener;
                }
            }

            if (BusStarted != null)
            {
                foreach (var listener in BusStarted.GetInvocationList().Cast <BusStartedEventHandler>())
                {
                    rebusEvents.BusStarted += listener;
                }
            }

            if (BusStopped != null)
            {
                foreach (var listener in BusStopped.GetInvocationList().Cast <BusStoppedEventHandler>())
                {
                    rebusEvents.BusStopped += listener;
                }
            }

            if (BeforeTransportMessage != null)
            {
                foreach (var listener in BeforeTransportMessage.GetInvocationList().Cast <BeforeTransportMessageEventHandler>())
                {
                    rebusEvents.BeforeTransportMessage += listener;
                }
            }

            if (AfterTransportMessage != null)
            {
                foreach (var listener in AfterTransportMessage.GetInvocationList().Cast <AfterTransportMessageEventHandler>())
                {
                    rebusEvents.AfterTransportMessage += listener;
                }
            }

            if (PoisonMessage != null)
            {
                foreach (var listener in PoisonMessage.GetInvocationList().Cast <PoisonMessageEventHandler>())
                {
                    rebusEvents.PoisonMessage += listener;
                }
            }

            if (UncorrelatedMessage != null)
            {
                foreach (var listener in UncorrelatedMessage.GetInvocationList().Cast <UncorrelatedMessageEventHandler>())
                {
                    rebusEvents.UncorrelatedMessage += listener;
                }
            }

            if (MessageAudited != null)
            {
                foreach (var listener in MessageAudited.GetInvocationList().Cast <MessageAuditedEventHandler>())
                {
                    rebusEvents.MessageAudited += listener;
                }
            }

            if (AfterHandling != null)
            {
                foreach (var listener in AfterHandling.GetInvocationList().Cast <AfterHandlingEventHandler>())
                {
                    rebusEvents.AfterHandling += listener;
                }
            }

            if (BeforeHandling != null)
            {
                foreach (var listener in BeforeHandling.GetInvocationList().Cast <BeforeHandlingEventHandler>())
                {
                    rebusEvents.BeforeHandling += listener;
                }
            }

            if (OnHandlingError != null)
            {
                foreach (var listener in OnHandlingError.GetInvocationList().Cast <OnHandlingErrorEventHandler>())
                {
                    rebusEvents.OnHandlingError += listener;
                }
            }

            foreach (var messageMutator in MessageMutators)
            {
                rebusEvents.MessageMutators.Add(messageMutator);
            }

            foreach (var unitOfWorkManager in unitOfWorkManagers)
            {
                rebusEvents.AddUnitOfWorkManager(unitOfWorkManager);
            }
        }