Пример #1
0
        /// <summary>
        /// Call this method from a service implementation, when the service is invoked. It will then
        /// invoke the correct Listener event.
        /// </summary>
        /// <param name="message">The received message</param>
        /// <param name="messageProcessStatus">Process status of the message</param>
        public static void TriggerMessageReceiveEvent(
            ListenerRequest message,
            MessageProcessStatus messageProcessStatus
            )
        {
            // 1. Find the relevant Listener object
            ServiceHostBase currentServiceHost = OperationContext.Current.Host;

            if (currentServiceHost == null)
            {
                throw new CurrentServiceHostSearchFailedException();
            }

            Listener listener = null;

            lock (pHostList) {
                try {
                    listener = pHostList[currentServiceHost];
                } catch (KeyNotFoundException) {
                    // The listener was not found!
                }

                if (listener == null)
                {
                    throw new WcfListenerSearchFailedException(currentServiceHost);
                }
            }

            // 3. Invoke the event
            listener.TriggerInternalMessageReceiveEvent(message, messageProcessStatus);
        }
Пример #2
0
 /// <summary>
 /// Used by the public TriggerMessageReceiveEvent to trigger a message receive event
 /// on a particular Listener instance (this)
 /// </summary>
 /// <param name="message">The received message</param>
 /// <param name="messageProcessStatus">The message process status</param>
 protected void TriggerInternalMessageReceiveEvent(
     ListenerRequest message,
     MessageProcessStatus messageProcessStatus
     )
 {
     if (MessageReceive != null)
     {
         MessageReceive(message, messageProcessStatus);
     }
 }