public void TestParent() { var part1 = new ImapSinglePartBodyStructure("1", new MimeType("text", "plain"), null, null, null, "7bit", 0L, 0L); var part21 = new ImapSinglePartBodyStructure("2.1", new MimeType("text", "plain"), null, null, null, "7bit", 0L, 0L); var part21extended = new ImapExtendedSinglePartBodyStructure(part21, null, null, null, null, null); var part22 = new ImapSinglePartBodyStructure("2.2", new MimeType("text", "html"), null, null, null, "7bit", 0L, 0L); var part2 = new ImapMultiPartBodyStructure("2", new[] {part21extended, part22}, "alternative"); var part31 = new ImapSinglePartBodyStructure("3.1", new MimeType("text", "plain"), null, null, null, "7bit", 0L, 0L); var part3Envelope = new ImapEnvelope(null, null, null, null, null, null, null, null, null, null); var part3 = new ImapMessageRfc822BodyStructure("3", new MimeType("message", "rfc822"), null, null, null, "7bit", 0L, part3Envelope, part31, 0L); var root = new ImapMultiPartBodyStructure(string.Empty, new IImapBodyStructure[] {part1, part2, part3}, "mixed"); Assert.IsNull(root.ParentStructure); Assert.AreSame(root, part1.ParentStructure); Assert.AreSame(root, part2.ParentStructure); Assert.AreSame(root, part3.ParentStructure); Assert.AreSame(part2, part21extended.ParentStructure); Assert.AreSame(part2, part22.ParentStructure); Assert.AreSame(part3, part31.ParentStructure); }
public ImapMessageRfc822BodyStructure(string section, MimeType mediaType, IDictionary<string, string> parameters, string id, string description, string encoding, long size, ImapEnvelope envelope, IImapBodyStructure bodyStructure, long lineCount) : base(section, mediaType, parameters, id, description, encoding, size, lineCount) { if (envelope == null) throw new ArgumentNullException("envelope"); if (bodyStructure == null) throw new ArgumentNullException("bodyStructure"); this.Envelope = envelope; this.BodyStructure = bodyStructure; ImapBodyStructureUtils.SetParentStructure(this); }
private IImapBodyStructure BuildMultiPart() { var part1 = new ImapSinglePartBodyStructure("1", new MimeType("text", "plain"), null, null, null, "7bit", 0L, 0L); var part21 = new ImapSinglePartBodyStructure("2.1", new MimeType("text", "plain"), null, null, null, "7bit", 0L, 0L); var part22 = new ImapSinglePartBodyStructure("2.2", new MimeType("text", "html"), null, null, null, "7bit", 0L, 0L); var part2 = new ImapMultiPartBodyStructure("2", new[] {part21, part22}, "alternative"); var part31 = new ImapSinglePartBodyStructure("3.1", new MimeType("text", "plain"), null, null, null, "7bit", 0L, 0L); var part3Envelope = new ImapEnvelope(null, null, null, null, null, null, null, null, null, null); var part3 = new ImapMessageRfc822BodyStructure("3", new MimeType("message", "rfc822"), null, null, null, "7bit", 0L, part3Envelope, part31, 0L); return new ImapMultiPartBodyStructure(string.Empty, new IImapBodyStructure[] {part1, part2, part3}, "mixed"); }