Esempio n. 1
0
        internal void QueueWrite(byte[] data, int offset, int count)
        {
            this.bytesWritten   += count;
            this.lineTermination = MimeCommon.AdvanceLineTerminationState(this.lineTermination, data, offset, count);
            int num = (this.writeCount == 1) ? (this.currentWrite.Length - this.currentWrite.Count) : ((this.writeCount == 0) ? MimeWriter.QueuedWrite.QueuedWriteSize : 0);

            if (num >= count)
            {
                if (this.writeCount == 0)
                {
                    MimeWriter.QueuedWrite queuedWrite = default(MimeWriter.QueuedWrite);
                    this.PushWrite(ref queuedWrite);
                }
                this.currentWrite.Append(data, offset, count);
                return;
            }
            MimeWriter.QueuedWrite queuedWrite2 = default(MimeWriter.QueuedWrite);
            if (count < MimeWriter.QueuedWrite.QueuedWriteSize && this.writeCount > 0)
            {
                queuedWrite2 = this.currentWrite;
            }
            this.FlushWriteQueue();
            if (count < MimeWriter.QueuedWrite.QueuedWriteSize && queuedWrite2.Length > 0)
            {
                queuedWrite2.Reset();
                queuedWrite2.Append(data, offset, count);
                this.PushWrite(ref queuedWrite2);
                return;
            }
            this.data.Write(data, offset, count);
        }
Esempio n. 2
0
 private void PushWrite(ref MimeWriter.QueuedWrite write)
 {
     if (this.writeQueue == null)
     {
         this.writeQueue = new MimeWriter.QueuedWrite[16];
         this.writeCount = 0;
     }
     else if (this.writeQueue.Length == this.writeCount)
     {
         MimeWriter.QueuedWrite[] destinationArray = new MimeWriter.QueuedWrite[this.writeQueue.Length * 2];
         Array.Copy(this.writeQueue, 0, destinationArray, 0, this.writeQueue.Length);
         for (int i = 0; i < this.writeQueue.Length; i++)
         {
             this.writeQueue[i] = default(MimeWriter.QueuedWrite);
         }
         this.writeQueue = destinationArray;
     }
     if (this.writeCount != 0)
     {
         this.writeQueue[this.writeCount - 1] = this.currentWrite;
     }
     this.writeQueue[this.writeCount++] = write;
     this.currentWrite = write;
 }