예제 #1
0
 public Result ParseFields(ref Stream dataStream, DataReader reader)
 {
     var result = reader.ReadData(ref dataStream);
     var headers = new string(result.Data);
     headers = m_UnfoldPattern.RegularExpression.Replace(headers, " ");
      IList<RFC822.Field> fields = new List<RFC822.Field>();
     Parse(ref fields, ref headers);
     return new Result()
         {
             Data = fields,
             FulfilledCritera = result.FulfilledCritera
         };
 }
예제 #2
0
        public Result ParseFields(ref Stream dataStream, DataReader reader)
        {
            var result  = reader.ReadData(ref dataStream);
            var headers = new string(result.Data);

            headers = m_UnfoldPattern.RegularExpression.Replace(headers, " ");
            IList <RFC822.Field> fields = new List <RFC822.Field>();

            Parse(ref fields, ref headers);
            return(new Result()
            {
                Data = fields,
                FulfilledCritera = result.FulfilledCritera
            });
        }
예제 #3
0
        private string ReadDiscreteBody(ref Stream dataStream, ref IEntity entity, ref string body)
        {
            StringBuilder sBuilder;
            char[] cLine;
            string currentLine, boundary;
            bool bContinue = true;

            int fulFilledCriteria;

            var dataReader = new DataReader(m_EndOfMessageCriteria, new EndOfLineStrategy());

            sBuilder = new StringBuilder();
            do
            {
                var result = dataReader.ReadData(ref dataStream);
                cLine = result.Data;
                currentLine = new string(cLine);
                boundary = m_delimiterFinder.FindDelimiter(ref entity, ref currentLine);
                if (!string.IsNullOrEmpty(boundary))
                {
                    break;
                }

                // Have we found the end of this message?
                if (result.FulfilledCritera < 0)
                {
                    boundary = string.Empty;
                    break;
                }
                sBuilder.Append(result.Data);
            }
            while (bContinue);

            body = sBuilder.ToString();
            sBuilder.Append(cLine);
            m_Source.Append(sBuilder);
            return boundary;
        }
예제 #4
0
        private string FindStartDelimiter(ref Stream dataStream, ref IEntity entity)
        {
            int fulFilledCriteria;
            string line, delimiter;

            var dataReader = new DataReader(m_EndOfMessageCriteria, new EndOfLineStrategy());
            do
            {
                var result = dataReader.ReadData(ref dataStream);
                fulFilledCriteria = result.FulfilledCritera;
                line = new string(result.Data);
                m_Source.Append(line);
                if (result.FulfilledCritera == 0)
                {
                    delimiter = string.Empty;
                    break;
                }

                delimiter = m_delimiterFinder.FindDelimiter(ref entity, ref line);
                if (!string.IsNullOrEmpty(delimiter))
                {
                    break;
                }
            }
            while (fulFilledCriteria >= 0);
            return delimiter;
        }
예제 #5
0
        protected DataReader.Result ReadHeaders(ref Stream dataStream)
        {
            var dataReader = new DataReader(m_EndOfMessageCriteria, new NullLineStrategy());

            return(dataReader.ReadData(ref dataStream));
        }