コード例 #1
0
ファイル: MtomMessageEncoder.cs プロジェクト: HongGit/wcf
        internal XmlDictionaryWriter TakeStreamedWriter(Stream stream, string startInfo, string boundary, string startUri, bool writeMessageHeaders)
        {
            if (_streamedWriterPool == null)
            {
                lock (_thisLock)
                {
                    if (_streamedWriterPool == null)
                    {
                        _streamedWriterPool = new SynchronizedPool <XmlDictionaryWriter>(MaxWritePoolSize);
                    }
                }
            }
            XmlDictionaryWriter xmlWriter = _streamedWriterPool.Take();

            if (xmlWriter == null)
            {
                xmlWriter = XmlMtomWriter.Create(stream, _writeEncoding, int.MaxValue, startInfo, boundary, startUri, writeMessageHeaders, false);
                if (WcfEventSource.Instance.WritePoolMissIsEnabled())
                {
                    WcfEventSource.Instance.WritePoolMiss(xmlWriter.GetType().Name);
                }
            }
            else
            {
                ((IXmlMtomWriterInitializer)xmlWriter).SetOutput(stream, _writeEncoding, int.MaxValue, startInfo, boundary, startUri, writeMessageHeaders, false);
            }
            return(xmlWriter);
        }
コード例 #2
0
ファイル: MtomMessageEncoder.cs プロジェクト: HongGit/wcf
        internal XmlReader TakeStreamedReader(Stream stream, string contentType, bool isMtomContentType)
        {
            if (_streamedReaderPool == null)
            {
                lock (_thisLock)
                {
                    if (_streamedReaderPool == null)
                    {
                        _streamedReaderPool = new SynchronizedPool <XmlDictionaryReader>(MaxReadPoolSize);
                    }
                }
            }
            XmlDictionaryReader xmlReader = _streamedReaderPool.Take();

            try
            {
                if (contentType == null || isMtomContentType)
                {
                    if (xmlReader != null && xmlReader is IXmlMtomReaderInitializer)
                    {
                        ((IXmlMtomReaderInitializer)xmlReader).SetInput(stream, MtomMessageEncoderFactory.GetSupportedEncodings(), contentType, ReaderQuotas, MaxBufferSize, _onStreamedReaderClose);
                    }
                    else
                    {
                        xmlReader = XmlMtomReader.Create(stream, MtomMessageEncoderFactory.GetSupportedEncodings(), contentType, ReaderQuotas, MaxBufferSize, _onStreamedReaderClose);
                        if (WcfEventSource.Instance.ReadPoolMissIsEnabled())
                        {
                            WcfEventSource.Instance.ReadPoolMiss(xmlReader.GetType().Name);
                        }
                    }
                }
                else
                {
                    if (xmlReader != null && xmlReader is IXmlTextReaderInitializer)
                    {
                        ((IXmlTextReaderInitializer)xmlReader).SetInput(stream, TextMessageEncoderFactory.GetEncodingFromContentType(contentType, ContentEncodingMap), ReaderQuotas, _onStreamedReaderClose);
                    }
                    else
                    {
                        xmlReader = XmlDictionaryReader.CreateTextReader(stream, TextMessageEncoderFactory.GetEncodingFromContentType(contentType, ContentEncodingMap), ReaderQuotas, _onStreamedReaderClose);
                        if (WcfEventSource.Instance.ReadPoolMissIsEnabled())
                        {
                            WcfEventSource.Instance.ReadPoolMiss(xmlReader.GetType().Name);
                        }
                    }
                }
            }
            catch (FormatException fe)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(
                                                                              SR.SFxErrorCreatingMtomReader, fe));
            }
            catch (XmlException xe)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(
                                                                              SR.SFxErrorCreatingMtomReader, xe));
            }

            return(xmlReader);
        }
コード例 #3
0
ファイル: BufferedMessageData.cs プロジェクト: yrest/wcf
        public RecycledMessageState DoTakeMessageState()
        {
            RecycledMessageState messageState = _messageState;

            if (messageState != null)
            {
                _messageState = null;
                return(messageState);
            }
            else
            {
                return(_messageStatePool.Take());
            }
        }
コード例 #4
0
ファイル: MtomMessageEncoder.cs プロジェクト: HongGit/wcf
 internal MtomMessageEncoder.MtomBufferedMessageData TakeBufferedReader(MtomMessageEncoder messageEncoder)
 {
     if (_bufferedReaderPool == null)
     {
         lock (_thisLock)
         {
             if (_bufferedReaderPool == null)
             {
                 _bufferedReaderPool = new SynchronizedPool <MtomMessageEncoder.MtomBufferedMessageData>(MaxReadPoolSize);
             }
         }
     }
     MtomMessageEncoder.MtomBufferedMessageData messageData = _bufferedReaderPool.Take();
     if (messageData == null)
     {
         messageData = new MtomMessageEncoder.MtomBufferedMessageData(messageEncoder, MaxPooledXmlReadersPerMessage);
         if (WcfEventSource.Instance.ReadPoolMissIsEnabled())
         {
             WcfEventSource.Instance.ReadPoolMiss(messageData.GetType().Name);
         }
     }
     return(messageData);
 }
コード例 #5
0
ファイル: MtomMessageEncoder.cs プロジェクト: HongGit/wcf
        internal MtomMessageEncoder.MtomBufferedMessageWriter TakeBufferedWriter(MtomMessageEncoder messageEncoder)
        {
            if (_bufferedWriterPool == null)
            {
                lock (_thisLock)
                {
                    if (_bufferedWriterPool == null)
                    {
                        _bufferedWriterPool = new SynchronizedPool <MtomMessageEncoder.MtomBufferedMessageWriter>(MaxWritePoolSize);
                    }
                }
            }

            MtomMessageEncoder.MtomBufferedMessageWriter messageWriter = _bufferedWriterPool.Take();
            if (messageWriter == null)
            {
                messageWriter = new MtomMessageEncoder.MtomBufferedMessageWriter(messageEncoder);
                if (WcfEventSource.Instance.WritePoolMissIsEnabled())
                {
                    WcfEventSource.Instance.WritePoolMiss(messageWriter.GetType().Name);
                }
            }
            return(messageWriter);
        }