System.Xml.XmlDictionaryWriter.WriteValue C# (CSharp) Method

WriteValue() public method

public WriteValue ( IStreamProvider value ) : void
value IStreamProvider
return void
        public virtual void WriteValue(IStreamProvider value)
        {
            if (value == null)
                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(value)));

            Stream stream = value.GetStream();
            if (stream == null)
                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.XmlInvalidStream)));
            int blockSize = 256;
            int bytesRead = 0;
            byte[] block = new byte[blockSize];
            while (true)
            {
                bytesRead = stream.Read(block, 0, blockSize);
                if (bytesRead > 0)
                    WriteBase64(block, 0, bytesRead);
                else
                    break;
                if (blockSize < 65536 && bytesRead == blockSize)
                {
                    blockSize = blockSize * 16;
                    block = new byte[blockSize];
                }
            }
            value.ReleaseStream(stream);
        }

Same methods

XmlDictionaryWriter::WriteValue ( System.Guid value ) : void
XmlDictionaryWriter::WriteValue ( System value ) : void
XmlDictionaryWriter::WriteValue ( System.TimeSpan value ) : void
XmlDictionaryWriter::WriteValue ( UniqueId value ) : void
XmlDictionaryWriter::WriteValue ( XmlDictionaryString value ) : void

Usage Example

        protected override void OnWriteAddressHeaderContents (XmlDictionaryWriter writer)
        {
            writer.WriteStartElement(XD.DotNetAtomicTransactionExternalDictionary.LocalTransactionId,
                                     XD.DotNetAtomicTransactionExternalDictionary.Namespace);

            writer.WriteValue(this.transactionId);
            writer.WriteEndElement();

            if (this.contextId != null)
            {
                writer.WriteStartElement(XD.DotNetAtomicTransactionExternalDictionary.ContextId,
                                         XD.DotNetAtomicTransactionExternalDictionary.Namespace);

                writer.WriteValue(this.contextId);
                writer.WriteEndElement();
            }

            if (this.tokenId != null)
            {
                writer.WriteStartElement(XD.DotNetAtomicTransactionExternalDictionary.TokenId,
                                         XD.DotNetAtomicTransactionExternalDictionary.Namespace);

                writer.WriteValue(this.tokenId);
                writer.WriteEndElement();
            }
        }
All Usage Examples Of System.Xml.XmlDictionaryWriter::WriteValue