/// <summary> /// Create MimeEntity from the given bytes /// </summary> /// <param name="bytes">The bytes to read</param> /// <returns>The parsed MimeEntity</returns> public static MimeEntity CreateFrom(byte[] bytes, bool throwOnInvalidContentType) { MimeReader reader = new MimeReader(bytes, throwOnInvalidContentType); MimeEntity entity = reader.CreateMimeEntity(); return(entity); }
/// <summary> /// Sets the type of the content. /// </summary> /// <param name="contentType">Type of the content.</param> internal void SetContentType(ContentType contentType) { ContentType = contentType; ContentType.MediaType = MimeReader.GetMediaType(contentType.MediaType); MediaMainType = MimeReader.GetMediaMainType(contentType.MediaType); MediaSubType = MimeReader.GetMediaSubType(contentType.MediaType); }
/// <summary> /// Initializes a new instance of the <see cref="MimeEntity"/> class. /// </summary> public MimeEntity() { Children = new List <MimeEntity>(); Headers = new NameValueCollection(); ContentType = MimeReader.GetContentType(string.Empty); Parent = null; _contentBytes = new List <byte[]>(); RawContent = new MemoryStream(); ContentTransferEncoding = System.Net.Mime.TransferEncoding.SevenBit; // RFC 2045 -- "Content-Transfer-Encoding: 7BIT" is assumed if the Content-Transfer-Encoding header field is not present. }
/// <summary> /// Adds the child entity. /// </summary> /// <param name="entity">The entity.</param> private void AddChildEntity(MimeEntity entity, Queue <byte[]> lines) { /*if (entity == null) * { * return; * } * * if (lines == null) * { * return; * }*/ MimeReader reader = new MimeReader(entity, lines, _throwOnInvalidContentType); MimeEntity childEntity = reader.CreateMimeEntity(); entity.Children.Add(childEntity); byte[] innerBytes = childEntity.RawContent.ToArray(); entity.RawContent.Write(innerBytes, 0, innerBytes.Length); }
/// <summary> /// Adds the child entity. /// </summary> /// <param name="entity">The entity.</param> private void AddChildEntity(MimeEntity entity, Queue<byte[]> lines) { /*if (entity == null) { return; } if (lines == null) { return; }*/ MimeReader reader = new MimeReader(entity, lines, _throwOnInvalidContentType); MimeEntity childEntity = reader.CreateMimeEntity(); entity.Children.Add(childEntity); byte[] innerBytes = childEntity.RawContent.ToArray(); entity.RawContent.Write(innerBytes, 0, innerBytes.Length); }
/// <summary> /// Create MimeEntity from the given bytes /// </summary> /// <param name="bytes">The bytes to read</param> /// <returns>The parsed MimeEntity</returns> public static MimeEntity CreateFrom(byte[] bytes, bool throwOnInvalidContentType) { MimeReader reader = new MimeReader(bytes, throwOnInvalidContentType); MimeEntity entity = reader.CreateMimeEntity(); return entity; }
/// <summary> /// Adds the child entity. /// </summary> /// <param name="entity">The entity.</param> private void AddChildEntity(MimeEntity entity, Queue<string> lines) { /*if (entity == null) { return; } if (lines == null) { return; }*/ MimeReader reader = new MimeReader(entity, lines); entity.Children.Add(reader.CreateMimeEntity()); }