Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 public override sealed MimeNode Clone()
 {
     var dateHeader = new DateHeader(this.Name, this.HeaderId);
     this.CopyTo(dateHeader);
     return dateHeader;
 }