예제 #1
0
        private string ReadDiscreteEntity(ref Stream dataStream, ref IEntity entity)
        {
            string body;
            string delimiter;

            body      = string.Empty;
            delimiter = ReadDiscreteBody(ref dataStream, ref entity, ref body);

            string encoding = string.Empty;

            foreach (RFC822.Field field in entity.Fields)
            {
                if (field is ContentTransferEncodingField)
                {
                    ContentTransferEncodingField transferField = field as ContentTransferEncodingField;
                    encoding = transferField.Encoding;
                    break;
                }
            }

            foreach (RFC2045.IDecoder decoder in m_Decoders)
            {
                if (decoder.CanDecode(encoding))
                {
                    entity.Body = decoder.Decode(ref body);
                    break;
                }
            }

            return(delimiter);
        }
        public override void Parse(ref IList <RFC822.Field> fields, ref string fieldString)
        {
            MatchCollection matches = m_Encoding.Matches(fieldString);

            foreach (Match match in matches)
            {
                Match enc;
                ContentTransferEncodingField tmpTransfer = new ContentTransferEncodingField();
                enc = m_Mechanism.Match(match.Value);
                tmpTransfer.Name     = "Content-Transfer-Encoding";
                tmpTransfer.Encoding = enc.Value;
                fields.Add(tmpTransfer);
            }
        }