Exemplo n.º 1
0
        // Token: 0x0600025C RID: 604 RVA: 0x0000BAE0 File Offset: 0x00009CE0
        internal static LineTerminationState AdvanceLineTerminationState(LineTerminationState previousLineTerminationState, byte[] data, int offset, int count)
        {
            if (count == 0)
            {
                return(previousLineTerminationState);
            }
            byte b = data[offset + count - 1];

            if (b == 13)
            {
                return(LineTerminationState.CR);
            }
            if (b != 10)
            {
                return(LineTerminationState.Other);
            }
            if (count >= 2)
            {
                if (data[offset + count - 2] == 13)
                {
                    return(LineTerminationState.CRLF);
                }
                return(LineTerminationState.Other);
            }
            else
            {
                if (previousLineTerminationState == LineTerminationState.CR)
                {
                    return(LineTerminationState.CRLF);
                }
                return(LineTerminationState.Other);
            }
        }
Exemplo n.º 2
0
 internal static LineTerminationState AdvanceLineTerminationState(LineTerminationState previousLineTerminationState, byte[] data, int offset, int count)
 {
     if (count == 0)
         return previousLineTerminationState;
     switch (data[offset + count - 1]) {
         case 13:
             return LineTerminationState.CR;
         case 10:
             if (count >= 2)
                 return (int) data[offset + count - 2] == 13 ? LineTerminationState.CRLF : LineTerminationState.Other;
             return previousLineTerminationState == LineTerminationState.CR ? LineTerminationState.CRLF : LineTerminationState.Other;
         default:
             return LineTerminationState.Other;
     }
 }
Exemplo n.º 3
0
 protected virtual void Dispose(bool disposing)
 {
     if (data == null)
         return;
     try {
         if (!disposing)
             return;
         while (partDepth != 0)
             this.EndPart();
         this.FlushWriteQueue();
         if (lineTermination == LineTerminationState.CRLF)
             return;
         if (lineTermination == LineTerminationState.CR)
             data.Write(MimeString.CrLf, 1, 1);
         else
             data.Write(MimeString.CrLf, 0, MimeString.CrLf.Length);
         lineTermination = LineTerminationState.CRLF;
     } finally {
         if (disposing) {
             if (encodedPartContent != null)
                 encodedPartContent.Dispose();
             if (partContent != null)
                 partContent.Dispose();
             data.Dispose();
         }
         state = MimeWriteState.Complete;
         encodedPartContent = null;
         partContent = null;
         data = null;
     }
 }
Exemplo n.º 4
0
 internal void QueueWrite(byte[] data, int offset, int count)
 {
     bytesWritten += count;
     lineTermination = MimeCommon.AdvanceLineTerminationState(lineTermination, data, offset, count);
     if ((writeCount == 1 ? currentWrite.Length - currentWrite.Count : (writeCount == 0 ? QueuedWrite.QueuedWriteSize : 0)) >= count) {
         if (writeCount == 0) {
             var write = new QueuedWrite();
             this.PushWrite(ref write);
         }
         currentWrite.Append(data, offset, count);
     } else {
         var write = new QueuedWrite();
         if (count < QueuedWrite.QueuedWriteSize && writeCount > 0)
             write = currentWrite;
         this.FlushWriteQueue();
         if (count < QueuedWrite.QueuedWriteSize && write.Length > 0) {
             write.Reset();
             write.Append(data, offset, count);
             this.PushWrite(ref write);
         } else
             this.data.Write(data, offset, count);
     }
 }