private int UpdateHopCount(Message message, out MessageHeader hopHeader, out ulong currentValue)
        {
            int index = -1;

            currentValue = ulong.MaxValue;
            hopHeader    = null;
            try
            {
                index = message.Headers.FindHeader("Hops", "http://schemas.microsoft.com/net/2006/05/peer/HopCount");
                if (index != -1)
                {
                    ulong num2;
                    currentValue = PeerMessageHelpers.GetHeaderULong(message.Headers, index);
                    currentValue = num2 = (ulong)(currentValue - 1L);
                    hopHeader    = MessageHeader.CreateHeader("Hops", "http://schemas.microsoft.com/net/2006/05/peer/HopCount", num2, false);
                }
            }
            catch (MessageHeaderException exception)
            {
                System.ServiceModel.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning);
            }
            catch (CommunicationException exception2)
            {
                System.ServiceModel.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Warning);
            }
            catch (SerializationException exception3)
            {
                System.ServiceModel.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception3, TraceEventType.Warning);
            }
            catch (XmlException exception4)
            {
                System.ServiceModel.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception4, TraceEventType.Warning);
            }
            return(index);
        }
Exemplo n.º 2
0
        int UpdateHopCount(Message message, out MessageHeader hopHeader, out ulong currentValue)
        {
            int index = -1;

            currentValue = PeerTransportConstants.MaxHopCount;
            hopHeader    = null;
            try
            {
                // If a message contains multiple Hopcounts with our name and namespace or the message can't deserialize to a ulong then ignore the HopCount
                index = message.Headers.FindHeader(PeerStrings.HopCountElementName, PeerStrings.HopCountElementNamespace);
                if (index != -1)
                {
                    currentValue = PeerMessageHelpers.GetHeaderULong(message.Headers, index);
                    hopHeader    = MessageHeader.CreateHeader(PeerStrings.HopCountElementName, PeerStrings.HopCountElementNamespace, --currentValue, false);
                }
            }
            catch (MessageHeaderException e)
            {
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Warning);
            }
            catch (CommunicationException e)
            {
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Warning);
            }
            catch (SerializationException e)
            {
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Warning);
            }
            catch (XmlException e)
            {
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Warning);
            }
            Fx.Assert((index == -1) || (hopHeader != null), "Could not successfully create new HopCount Header!");
            return(index);
        }