Exemple #1
0
 internal void WriteBody(byte[] buffer, int offset, int count)
 {
     if (buffer == null)
     {
         throw new ArgumentNullException("buffer");
     }
     if (count < 0 || offset < 0)
     {
         throw new ArgumentOutOfRangeException(XmlaSR.DimeRecord_OffsetAndCountShouldBePositive);
     }
     if (this.m_closed)
     {
         throw new InvalidOperationException(XmlaSR.DimeRecord_StreamIsClosed);
     }
     if (this.m_ioMode != IOModeEnum.WriteOnly)
     {
         throw new InvalidOperationException(XmlaSR.DimeRecord_WriteNotAllowed);
     }
     if (this.m_chunked)
     {
         if (this.m_bytesReadWritten + count >= this.ChunkSize)
         {
             this.WriteChunkedPayload(false, false, buffer, offset, count);
             return;
         }
         if (this.m_bodyStreamBuffer == null)
         {
             this.m_bodyStreamBuffer = new MemoryStream((count < 512) ? 512 : count);
         }
         this.m_bodyStreamBuffer.Write(buffer, offset, count);
         this.m_bytesReadWritten += count;
         return;
     }
     else
     {
         if (this.m_bytesReadWritten + count > this.m_contentLength)
         {
             throw new Exception(XmlaSR.DimeRecord_ContentLengthExceeded);
         }
         if (!this.m_headerWritten)
         {
             this.WriteHeader(false, false, (long)this.m_contentLength);
             this.m_headerWritten = true;
         }
         this.m_stream.Write(buffer, offset, count);
         this.m_bytesReadWritten += count;
         if (this.m_bytesReadWritten == this.m_contentLength)
         {
             DimeRecord.WritePadding(this.m_stream, this.m_bytesReadWritten);
         }
         return;
     }
 }
Exemple #2
0
        private void WriteChunkedPayload(bool endOfRecord, bool endOfMessage, byte[] bytes, int offset, int count)
        {
            byte[] array = null;
            int    num   = 0;

            if (this.m_bodyStreamBuffer != null && this.m_bodyStreamBuffer.Length > 0L)
            {
                array = this.m_bodyStreamBuffer.GetBuffer();
                this.m_bodyStreamBuffer = null;
                num = this.m_bytesReadWritten;
                this.m_bytesReadWritten = 0;
            }
            this.WriteHeader(endOfRecord, endOfMessage, (long)(count + num));
            if (array != null)
            {
                this.m_stream.Write(array, 0, num);
            }
            if (bytes != null)
            {
                this.m_stream.Write(bytes, offset, count);
            }
            DimeRecord.WritePadding(this.m_stream, count + num);
        }