Пример #1
0
        bool IsInvalid(TMessage message)
        {
            UniqueId messageId = OperationContext.Current.IncomingMessageHeaders.MessageId;

            if (messageId == null)
            {
                if (TD.DiscoveryMessageWithNullMessageIdIsEnabled())
                {
                    TD.DiscoveryMessageWithNullMessageId(null, ProtocolStrings.TracingStrings.Bye);
                }

                return(true);
            }

            EventTraceActivity eventTraceActivity = null;

            if (Fx.Trace.IsEtwProviderEnabled)
            {
                eventTraceActivity = EventTraceActivityHelper.TryExtractActivity(OperationContext.Current.IncomingMessage);
            }

            if (this.announcementServiceImpl.IsDuplicate(messageId))
            {
                if (TD.DuplicateDiscoveryMessageIsEnabled())
                {
                    TD.DuplicateDiscoveryMessage(eventTraceActivity, ProtocolStrings.TracingStrings.Bye, messageId.ToString());
                }

                return(true);
            }
            else if (this.ValidateContent(message))
            {
                return(false);
            }
            else
            {
                if (TD.DiscoveryMessageWithInvalidContentIsEnabled())
                {
                    TD.DiscoveryMessageWithInvalidContent(eventTraceActivity, ProtocolStrings.TracingStrings.Bye, messageId.ToString());
                }

                return(true);
            }
        }
Пример #2
0
        internal static bool EnsureMessageId()
        {
            if (OperationContext.Current.IncomingMessageHeaders.MessageId == null)
            {
                if (TD.DiscoveryMessageWithNullMessageIdIsEnabled())
                {
                    TD.DiscoveryMessageWithNullMessageId(
                        null,
                        string.Format(
                            CultureInfo.InvariantCulture,
                            "{0}/{1}",
                            ProtocolStrings.TracingStrings.Probe,
                            ProtocolStrings.TracingStrings.Resolve));
                }

                return(false);
            }

            return(true);
        }