コード例 #1
0
ファイル: DSNParser.cs プロジェクト: DM-TOR/nhin-d
 private static List<HeaderCollection> PerRecipientList(IEnumerable<Header> fields)
 {
     List<HeaderCollection> perRecipientList = new List<HeaderCollection>();
     HeaderCollection headers = new HeaderCollection();
     foreach (var dsnField in fields)
     {
         if(dsnField.IsNamed(SeperatorHeader) && ! headers.IsNullOrEmpty()) 
         {
             perRecipientList.Add(headers);
             headers = new HeaderCollection();
             continue;
         }              
         headers.Add(dsnField);
     }
     if (! headers.IsNullOrEmpty())
     {
         perRecipientList.Add(headers);
     }
     return perRecipientList;
 }
コード例 #2
0
ファイル: DSNParser.cs プロジェクト: DM-TOR/nhin-d
        /// <summary>
        /// Extract DSN fields 
        /// Fields are formatted just like MIME headers, but embedded within the Body of MimeEntity instead
        /// </summary>
        /// <param name="fieldEntity">Source entity</param>
        /// <returns>Collection of fields</returns>
        public static HeaderCollection ParseDSNFields(MimeEntity fieldEntity)
        {
            if (fieldEntity == null)
            {
                throw new ArgumentNullException("fieldEntity");
            }
            Body DSNBody = fieldEntity.Body;
            if (DSNBody == null)
            {
                throw new DSNException(DSNError.InvalidDSNBody);
            }
            HeaderCollection DSNFields = null;
            try
            {
                DSNFields = new HeaderCollection(MimeSerializer.Default.DeserializeHeaders(DSNBody.TrimEmptyLines()));
            }
            catch (Exception ex)
            {
                throw new DSNException(DSNError.InvalidDSNFields, ex);
            }

            if (DSNFields.IsNullOrEmpty())
            {
                throw new DSNException(DSNError.InvalidDSNFields);
            }

            return DSNFields;
        }
コード例 #3
0
ファイル: DSNParser.cs プロジェクト: DM-TOR/nhin-d
        /// <summary>
        /// Extract per-recipient dsn headers as a collection
        /// Fields are formatted just like MIME headers, but embedded within the Body of MimeEntity instead
        /// </summary>
        /// <param name="fieldEntity">Source entity</param>
        /// <returns>Collection of <see cref="HeaderCollection"/></returns>
        public static List<HeaderCollection> ParsePerRecientFields(MimeEntity fieldEntity)
        {
            if (fieldEntity == null)
            {
                throw new ArgumentNullException("fieldEntity");
            }
            Body dsnBody = fieldEntity.Body;
            if (dsnBody == null)
            {
                throw new DSNException(DSNError.InvalidDSNBody);
            }
            HeaderCollection dsnFields = new HeaderCollection();
            try
            {
                dsnFields.Add(new HeaderCollection(MimeSerializer.Default.DeserializeHeaders(dsnBody.PerRecipientSeperator()))
                    , PerRecipientFieldList());
            }
            catch (Exception ex)
            {
                throw new DSNException(DSNError.InvalidDSNFields, ex);
            }

            if (dsnFields.IsNullOrEmpty())
            {
                throw new DSNException(DSNError.InvalidDSNFields);
            }

            return PerRecipientList(dsnFields);
        }
コード例 #4
0
ファイル: MDNParser.cs プロジェクト: DM-TOR/nhin-d
        /// <summary>
        /// Extract MDN fields (RFC 3798 Section 3.1.*). 
        /// Fields are formatted just like MIME headers, but embedded within the Body of MimeEntity instead
        /// </summary>
        /// <param name="fieldEntity">Source entity</param>
        /// <returns>Collection of fields</returns>
        public static HeaderCollection ParseMDNFields(MimeEntity fieldEntity)
        {
            if (fieldEntity == null)
            {
                throw new ArgumentNullException("fieldEntity");
            }
            Body mdnBody = fieldEntity.Body;
            if (mdnBody == null)
            {
                throw new MDNException(MDNError.InvalidMDNBody);
            }
            HeaderCollection mdnFields = null;
            try
            {
                mdnFields = new HeaderCollection(MimeSerializer.Default.DeserializeHeaders(mdnBody.Text));
            }
            catch(Exception ex)
            {
                throw new MDNException(MDNError.InvalidMDNFields, ex);
            }

            if (mdnFields.IsNullOrEmpty())
            {
                throw new MDNException(MDNError.InvalidMDNFields);
            }

            return mdnFields;
        }