Example #1
0
        public sealed override MimeNode Clone()
        {
            AsciiTextHeader asciiTextHeader = new AsciiTextHeader(base.Name, base.HeaderId);

            this.CopyTo(asciiTextHeader);
            return(asciiTextHeader);
        }
Example #2
0
        internal static Header Create(string name, HeaderId headerId)
        {
            if (headerId < HeaderId.Unknown || headerId > (HeaderId)MimeData.nameIndex.Length)
            {
                throw new ArgumentException(Strings.InvalidHeaderId, "headerId");
            }
            if (headerId == HeaderId.Unknown)
            {
                throw new ArgumentException(Strings.CannotDetermineHeaderNameFromId, "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 ArgumentException("name");
            }
            return(header);
        }