/// <summary> /// Parses body from the specified stream /// </summary> /// <param name="owner">Owner MIME entity.</param> /// <param name="mediaType">MIME media type. For example: text/plain.</param> /// <param name="stream">Stream from where to read body.</param> /// <returns>Returns parsed body.</returns> /// <exception cref="ArgumentNullException">Is raised when <b>stream</b>, <b>mediaType</b> or <b>stream</b> is null reference.</exception> /// <exception cref="ParseException">Is raised when any parsing errors.</exception> protected new static MIME_b Parse(MIME_Entity owner, string mediaType, SmartStream stream) { if (owner == null) { throw new ArgumentNullException("owner"); } if (mediaType == null) { throw new ArgumentNullException("mediaType"); } if (stream == null) { throw new ArgumentNullException("stream"); } MIME_b_MessageRfc822 retVal = new MIME_b_MessageRfc822(); if (owner.ContentTransferEncoding != null && owner.ContentTransferEncoding.Equals("base64", StringComparison.OrdinalIgnoreCase)) { Stream decodedDataStream = new MemoryStream(); using (StreamReader reader = new StreamReader(stream)) { byte[] decoded = Convert.FromBase64String(reader.ReadToEnd()); decodedDataStream.Write(decoded, 0, decoded.Length); decodedDataStream.Seek(0, SeekOrigin.Begin); } //Create base64 decoder stream = new SmartStream(decodedDataStream, true); } retVal.m_pMessage = Mail_Message.ParseFromStream(stream); return(retVal); }
/// <summary> /// Parses body from the specified stream /// </summary> /// <param name="owner">Owner MIME entity.</param> /// <param name="mediaType">MIME media type. For example: text/plain.</param> /// <param name="stream">Stream from where to read body.</param> /// <returns>Returns parsed body.</returns> /// <exception cref="ArgumentNullException">Is raised when <b>stream</b>, <b>mediaType</b> or <b>stream</b> is null reference.</exception> /// <exception cref="ParseException">Is raised when any parsing errors.</exception> protected new static MIME_b Parse(MIME_Entity owner, string mediaType, SmartStream stream) { if (owner == null) { throw new ArgumentNullException("owner"); } if (mediaType == null) { throw new ArgumentNullException("mediaType"); } if (stream == null) { throw new ArgumentNullException("stream"); } MIME_b_MessageRfc822 retVal = new MIME_b_MessageRfc822(); if (owner.ContentTransferEncoding != null && owner.ContentTransferEncoding.Equals("base64", StringComparison.OrdinalIgnoreCase)) { Stream decodedDataStream = new MemoryStream(); using (StreamReader reader = new StreamReader(stream)) { byte[] decoded = Convert.FromBase64String(reader.ReadToEnd()); decodedDataStream.Write(decoded, 0, decoded.Length); decodedDataStream.Seek(0, SeekOrigin.Begin); } //Create base64 decoder stream = new SmartStream(decodedDataStream,true); } retVal.m_pMessage = Mail_Message.ParseFromStream(stream); return retVal; }