Ejemplo n.º 1
0
        public async Task<List<Body>> GetBodies(IByteStreamReader streamReader, ContentTypeFieldValue contentType, string transportEncoding)
        {
            var reader = new BufferedByteReader(streamReader);
           
            switch (contentType.Type)
            {
                case "multipart":
                    var bodyPartReader = new BodyReader(ContentType, Header.ContentTransferEncoding);

                    var bodies = await bodyPartReader.ReadBody(reader);
                    break;
                case "text":
                    var textString = "";
                    using (var memstream = await streamReader.GetMemoryStreamAsync())
                    {
                        using (var unEncoded = await MailMethods.UnEncode(memstream, Header.ContentTransferEncoding))
                        {
                            using (var textReader = new StreamReader(unEncoded, Encoding.GetEncoding(Header.ContentType.Charset)))
                            {
                                textString = await textReader.ReadToEndAsync();
                            }
                        }
                    }
                    var textBody = new Body();
                    textBody.Content = (new MemoryStream(Encoding.Unicode.GetBytes(textString)));
                    break;
                case "image":
                case "audio":
                case "video":
                case "application":
                    var binaryBody = new Body();
                    binaryBody.Content = await streamReader.GetMemoryStreamAsync());
                    break;
            }
        }
 private async Task<string> ReadOneId(IByteStreamReader reader)
 {
     var valueBuilder = new StringBuilder();
     var nextByte = await reader.ReadByteAsync();
     while (nextByte != (byte)SpecialByte.RightAngledBracket)
     {
         valueBuilder.Append(Convert.ToChar(nextByte));
         nextByte = await reader.ReadByteAsync();
     }
     return valueBuilder.ToString();
 }
Ejemplo n.º 3
0
        private async Task <string> ReadOneId(IByteStreamReader reader)
        {
            var valueBuilder = new StringBuilder();
            var nextByte     = await reader.ReadByteAsync();

            while (nextByte != (byte)SpecialByte.RightAngledBracket)
            {
                valueBuilder.Append(Convert.ToChar(nextByte));
                nextByte = await reader.ReadByteAsync();
            }
            return(valueBuilder.ToString());
        }
Ejemplo n.º 4
0
        internal async Task ReadComment(IByteStreamReader reader)
        {
            var nextByte = await reader.ReadByteAsync();

            while (nextByte != (byte)SpecialByte.RightParernthesis)
            {
                if (nextByte == (byte)SpecialByte.BackSlash)
                {
                    nextByte = await reader.ReadByteAsync();
                }
                else
                {
                    if (nextByte == (byte)SpecialByte.LeftParenthesis)
                    {
                        await ReadComment(reader);
                    }
                }
                nextByte = await reader.ReadByteAsync();
            }
        }
Ejemplo n.º 5
0
        public async Task GetOneMail(IByteStreamReader streamReader)
        {
            var reader = new BufferedByteReader(streamReader);

            Received = DateTime.Now;
        }
Ejemplo n.º 6
0
 public BufferedByteReader(IByteStreamReader byteReader)
 {
     _byteReader = byteReader;
 }
Ejemplo n.º 7
0
        public async Task GetOneMail(IByteStreamReader streamReader)
        {
           var reader = new BufferedByteReader(streamReader);

            Received = DateTime.Now;
        }
Ejemplo n.º 8
0
 internal async Task ReadComment(IByteStreamReader reader)
 {
     var nextByte = await reader.ReadByteAsync();
     while (nextByte != (byte)SpecialByte.RightParernthesis)
     {
         if (nextByte == (byte)SpecialByte.BackSlash)
         {
             nextByte = await reader.ReadByteAsync();
         }
         else
         {
             if (nextByte == (byte)SpecialByte.LeftParenthesis)
             {
                 await ReadComment(reader);
             }
         }
         nextByte = await reader.ReadByteAsync();
     }
 }
Ejemplo n.º 9
0
 public BufferedByteReader(IByteStreamReader byteReader)
 {
     _byteReader = byteReader;
 }