コード例 #1
0
ファイル: Header.cs プロジェクト: Rhombulus/Mime
 internal static Header Create(string name, HeaderId headerId)
 {
     if (headerId < HeaderId.Unknown || headerId > (HeaderId) MimeData.nameIndex.Length)
         throw new System.ArgumentException(Resources.Strings.InvalidHeaderId, nameof(headerId));
     if (headerId == HeaderId.Unknown)
         throw new System.ArgumentException(Resources.Strings.CannotDetermineHeaderNameFromId, nameof(headerId));
     Header header;
     switch (MimeData.headerNames[(int) MimeData.nameIndex[(int) headerId]].headerType) {
         case HeaderType.AsciiText:
             header = new AsciiTextHeader(MimeData.headerNames[(int) MimeData.nameIndex[(int) headerId]].name, headerId);
             break;
         case HeaderType.Date:
             header = new DateHeader(MimeData.headerNames[(int) MimeData.nameIndex[(int) headerId]].name, headerId);
             break;
         case HeaderType.Received:
             header = new ReceivedHeader();
             break;
         case HeaderType.ContentType:
             header = new ContentTypeHeader();
             break;
         case HeaderType.ContentDisposition:
             header = new ContentDispositionHeader();
             break;
         case HeaderType.Address:
             header = new AddressHeader(MimeData.headerNames[(int) MimeData.nameIndex[(int) headerId]].name, headerId);
             break;
         default:
             header = new TextHeader(MimeData.headerNames[(int) MimeData.nameIndex[(int) headerId]].name, headerId);
             break;
     }
     if (!string.IsNullOrEmpty(name) && !header.MatchName(name))
         throw new System.ArgumentException("name");
     return header;
 }
コード例 #2
0
ファイル: ReceivedHeader.cs プロジェクト: Rhombulus/Mime
 public override sealed MimeNode Clone()
 {
     var receivedHeader = new ReceivedHeader();
     this.CopyTo(receivedHeader);
     return receivedHeader;
 }