示例#1
0
        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
            protected override XmlDictionaryWriter TakeXmlWriter(Stream stream)
            {
                XmlDictionaryWriter returnedWriter = _writer;

                if (returnedWriter == null)
                {
                    returnedWriter = XmlMtomWriter.Create(stream, _messageEncoder._writeEncoding, _maxSizeInBytes, _startInfo, _boundary, _startUri, _writeMessageHeaders, false);
                }
                else
                {
                    _writer = null;
                    ((IXmlMtomWriterInitializer)returnedWriter).SetOutput(stream, _messageEncoder._writeEncoding, _maxSizeInBytes, _startInfo, _boundary, _startUri, _writeMessageHeaders, false);
                }
                if (_messageEncoder._writeEncoding.WebName != "utf-8")
                {
                    returnedWriter.WriteStartDocument();
                }
                return(returnedWriter);
            }