Пример #1
0
 protected TransportOutputChannel(ChannelManagerBase channelManager, EndpointAddress to, Uri via, bool manualAddressing, System.ServiceModel.Channels.MessageVersion messageVersion) : base(channelManager)
 {
     this.manualAddressing = manualAddressing;
     this.messageVersion   = messageVersion;
     this.to  = to;
     this.via = via;
     if (!manualAddressing && (to != null))
     {
         Uri anonymousUri;
         if (to.IsAnonymous)
         {
             anonymousUri = this.messageVersion.Addressing.AnonymousUri;
         }
         else if (to.IsNone)
         {
             anonymousUri = this.messageVersion.Addressing.NoneUri;
         }
         else
         {
             anonymousUri = to.Uri;
         }
         XmlDictionaryString dictionaryTo = new ToDictionary(anonymousUri.AbsoluteUri).To;
         this.toHeader        = ToHeader.Create(anonymousUri, dictionaryTo, messageVersion.Addressing);
         this.anyHeadersToAdd = to.Headers.Count > 0;
     }
 }
        protected TransportOutputChannel(ChannelManagerBase channelManager, EndpointAddress to, Uri via, bool manualAddressing, MessageVersion messageVersion)
            : base(channelManager)
        {
            _manualAddressing = manualAddressing;
            _messageVersion   = messageVersion;
            _to  = to;
            _via = via;

            if (!manualAddressing && to != null)
            {
                Uri toUri;
                if (to.IsAnonymous)
                {
                    toUri = _messageVersion.Addressing.AnonymousUri;
                }
                else if (to.IsNone)
                {
                    toUri = _messageVersion.Addressing.NoneUri;
                }
                else
                {
                    toUri = to.Uri;
                }

                if (toUri != null)
                {
                    XmlDictionaryString dictionaryTo = new ToDictionary(toUri.AbsoluteUri).To;
                    _toHeader = ToHeader.Create(toUri, dictionaryTo, messageVersion.Addressing);
                }

                _anyHeadersToAdd = to.Headers.Count > 0;
            }

            if (FxTrace.Trace.IsEnd2EndActivityTracingEnabled)
            {
                _channelEventTraceActivity = EventTraceActivity.GetFromThreadOrCreate();
            }
        }
        public Message TryCreateMessage(byte[] buffer, int offset, int size, BufferManager bufferManager, BufferedMessageData messageData)
        {
            RelatesToHeader     header;
            MessageIDHeader     header2;
            XmlDictionaryString anonymous;
            int num6;
            XmlDictionaryString str2;
            int num  = offset;
            int num2 = size;
            int num3 = BinaryFormatParser.MatchBytes(buffer, num, num2, commonFragment);

            if (num3 == 0)
            {
                return(null);
            }
            num  += num3;
            num2 -= num3;
            num3  = BinaryFormatParser.MatchKey(buffer, num, num2);
            if (num3 == 0)
            {
                return(null);
            }
            int num4 = num;
            int num5 = num3;

            num  += num3;
            num2 -= num3;
            num3  = BinaryFormatParser.MatchBytes(buffer, num, num2, requestFragment1);
            if (num3 != 0)
            {
                num  += num3;
                num2 -= num3;
                num3  = BinaryFormatParser.MatchUniqueID(buffer, num, num2);
                if (num3 == 0)
                {
                    return(null);
                }
                int num7 = num;
                int num8 = num3;
                num  += num3;
                num2 -= num3;
                num3  = BinaryFormatParser.MatchBytes(buffer, num, num2, requestFragment2);
                if (num3 == 0)
                {
                    return(null);
                }
                num  += num3;
                num2 -= num3;
                if (BinaryFormatParser.MatchAttributeNode(buffer, num, num2))
                {
                    return(null);
                }
                header2 = MessageIDHeader.Create(BinaryFormatParser.ParseUniqueID(buffer, num7, num8), this.messageVersion.Addressing);
                header  = null;
                if (!this.readerSession.TryLookup(1, out anonymous))
                {
                    return(null);
                }
                num6 = (requestFragment1.Length + num8) + requestFragment2.Length;
            }
            else
            {
                num3 = BinaryFormatParser.MatchBytes(buffer, num, num2, responseFragment1);
                if (num3 == 0)
                {
                    return(null);
                }
                num  += num3;
                num2 -= num3;
                num3  = BinaryFormatParser.MatchUniqueID(buffer, num, num2);
                if (num3 == 0)
                {
                    return(null);
                }
                int num9  = num;
                int num10 = num3;
                num  += num3;
                num2 -= num3;
                num3  = BinaryFormatParser.MatchBytes(buffer, num, num2, responseFragment2);
                if (num3 == 0)
                {
                    return(null);
                }
                num  += num3;
                num2 -= num3;
                if (BinaryFormatParser.MatchAttributeNode(buffer, num, num2))
                {
                    return(null);
                }
                header    = RelatesToHeader.Create(BinaryFormatParser.ParseUniqueID(buffer, num9, num10), this.messageVersion.Addressing);
                header2   = null;
                anonymous = XD.Addressing10Dictionary.Anonymous;
                num6      = (responseFragment1.Length + num10) + responseFragment2.Length;
            }
            num6 += commonFragment.Length + num5;
            int key = BinaryFormatParser.ParseKey(buffer, num4, num5);

            if (!this.TryLookupKey(key, out str2))
            {
                return(null);
            }
            ActionHeader actionHeader = ActionHeader.Create(str2, this.messageVersion.Addressing);

            if (this.toHeader == null)
            {
                this.toHeader = ToHeader.Create(new Uri(anonymous.Value), this.messageVersion.Addressing);
            }
            int num12 = num6 - bodyFragment.Length;

            offset += num12;
            size   -= num12;
            Buffer.BlockCopy(bodyFragment, 0, buffer, offset, bodyFragment.Length);
            messageData.Open(new ArraySegment <byte>(buffer, offset, size), bufferManager);
            PatternMessage message = new PatternMessage(messageData, this.messageVersion);
            MessageHeaders headers = message.Headers;

            headers.AddActionHeader(actionHeader);
            if (header2 != null)
            {
                headers.AddMessageIDHeader(header2);
                headers.AddReplyToHeader(ReplyToHeader.AnonymousReplyTo10);
            }
            else
            {
                headers.AddRelatesToHeader(header);
            }
            headers.AddToHeader(this.toHeader);
            return(message);
        }