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 = XmlDictionaryWriter.CreateMtomWriter(stream, this.writeEncoding, int.MaxValue, startInfo, boundary, startUri, writeMessageHeaders, false);
                if (TD.WritePoolMissIsEnabled())
                {
                    TD.WritePoolMiss(xmlWriter.GetType().Name);
                }
            }
            else
            {
                ((IXmlMtomWriterInitializer)xmlWriter).SetOutput(stream, this.writeEncoding, int.MaxValue, startInfo, boundary, startUri, writeMessageHeaders, false);
            }
            return(xmlWriter);
        }
            XmlDictionaryWriter TakeStreamedWriter(Stream stream)
            {
                if (streamedWriterPool == null)
                {
                    lock (ThisLock)
                    {
                        if (streamedWriterPool == null)
                        {
                            streamedWriterPool = new SynchronizedPool <XmlDictionaryWriter>(maxWritePoolSize);
                        }
                    }
                }
                XmlDictionaryWriter xmlWriter = streamedWriterPool.Take();

                if (xmlWriter == null)
                {
                    xmlWriter = XmlDictionaryWriter.CreateTextWriter(stream, this.writeEncoding, false);
                    if (TD.WritePoolMissIsEnabled())
                    {
                        TD.WritePoolMiss(xmlWriter.GetType().Name);
                    }
                }
                else
                {
                    ((IXmlTextWriterInitializer)xmlWriter).SetOutput(stream, this.writeEncoding, false);
                }
                return(xmlWriter);
            }