public void StartPart() { this.AssertOpen(); MimeWriteState mimeWriteState = this.state; if (mimeWriteState == MimeWriteState.Complete || mimeWriteState == MimeWriteState.PartContent) { throw new InvalidOperationException(Strings.CannotStartPartHere); } if (this.partDepth != 0) { this.FlushHeader(); if (!this.currentPart.IsMultipart) { throw new InvalidOperationException(Strings.NonMultiPartPartsCannotHaveChildren); } if (!this.foundMimeVersion && this.forceMime && this.partDepth == 1) { this.WriteMimeVersion(); } this.Write(MimeString.CrLf, 0, MimeString.CrLf.Length); this.WriteBoundary(this.currentPart.Boundary, false); } MimeWriter.PartData partData = default(MimeWriter.PartData); this.PushPart(ref partData); this.state = MimeWriteState.StartPart; this.contentWritten = false; this.contentTransferEncoding = ContentTransferEncoding.SevenBit; }
private void PushPart(ref MimeWriter.PartData part) { if (this.partStack == null) { this.partStack = new MimeWriter.PartData[8]; this.partDepth = 0; } else if (this.partStack.Length == this.partDepth) { MimeWriter.PartData[] destinationArray = new MimeWriter.PartData[this.partStack.Length * 2]; Array.Copy(this.partStack, 0, destinationArray, 0, this.partStack.Length); for (int i = 0; i < this.partDepth; i++) { this.partStack[i] = default(MimeWriter.PartData); } this.partStack = destinationArray; } if (this.partDepth != 0) { this.partStack[this.partDepth - 1] = this.currentPart; } this.partStack[this.partDepth++] = part; this.currentPart = part; }