public HeaderInfo(MailHeaderID id, string name, bool isSingleton, bool isUserSettable, bool allowsUnicode) {
     ID = id;
     NormalizedName = name;
     IsSingleton = isSingleton;
     IsUserSettable = isUserSettable;
     AllowsUnicode = allowsUnicode;
 }
Пример #2
0
 internal static string GetString(MailHeaderID id)
 {
     MailHeaderID rid = id;
     if ((rid != MailHeaderID.Unknown) && (rid != (MailHeaderID.ZMaxEnumValue | MailHeaderID.Cc)))
     {
         return m_HeaderInfo[(int) id].NormalizedName;
     }
     return null;
 }
Пример #3
0
        internal static string GetString(MailHeaderID id)
        {
            switch (id)
            {
            case MailHeaderID.Unknown:
            case MailHeaderID.ZMaxEnumValue + 1:
                return(null);

            default:
                return(s_headerInfo[(int)id].NormalizedName);
            }
        }
Пример #4
0
        public override void Set(string name, string value)
        {
            if (Logging.On)
            {
                Logging.PrintInfo(Logging.Web, this, "Set", name.ToString() + "=" + value.ToString());
            }
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (name == string.Empty)
            {
                throw new ArgumentException(SR.GetString(SR.net_emptystringcall, nameof(name)), nameof(name));
            }

            if (value == string.Empty)
            {
                throw new ArgumentException(SR.GetString(SR.net_emptystringcall, nameof(value)), nameof(value));
            }

            if (!MimeBasePart.IsAscii(name, false))
            {
                throw new FormatException(SR.GetString(SR.InvalidHeaderName));
            }

            // normalize the case of well known headers
            name = MailHeaderInfo.NormalizeCase(name);

            MailHeaderID id = MailHeaderInfo.GetID(name);

            value = value.Normalize(Text.NormalizationForm.FormC);

            if (id == MailHeaderID.ContentType && part != null)
            {
                part.ContentType.Set(value.ToLower(CultureInfo.InvariantCulture), this);
            }
            else if (id == MailHeaderID.ContentDisposition && part is MimePart)
            {
                ((MimePart)part).ContentDisposition.Set(value.ToLower(CultureInfo.InvariantCulture), this);
            }
            else
            {
                base.Set(name, value);
            }
        }
Пример #5
0
#pragma warning disable CS8610 // Nullability of reference types in type of parameter doesn't match overridden member.
        public override void Set(string name, string value)
#pragma warning restore CS8610
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (name == string.Empty)
            {
                throw new ArgumentException(SR.Format(SR.net_emptystringcall, nameof(name)), nameof(name));
            }

            if (value == string.Empty)
            {
                throw new ArgumentException(SR.Format(SR.net_emptystringcall, nameof(value)), nameof(value));
            }

            if (!MimeBasePart.IsAscii(name, false))
            {
                throw new FormatException(SR.InvalidHeaderName);
            }

            // normalize the case of well known headers
            name = MailHeaderInfo.NormalizeCase(name);

            MailHeaderID id = MailHeaderInfo.GetID(name);

            value = value.Normalize(NormalizationForm.FormC);

            if (id == MailHeaderID.ContentType && _part != null)
            {
                _part.ContentType.Set(value.ToLowerInvariant(), this);
            }
            else if (id == MailHeaderID.ContentDisposition && _part is MimePart)
            {
                ((MimePart)_part).ContentDisposition !.Set(value.ToLowerInvariant(), this);
            }
            else
            {
                base.Set(name, value);
            }
        }
        public override void Add(string name, string value)
        {
            if (Logging.On)
            {
                Logging.PrintInfo(Logging.Web, this, "Add", name.ToString() + "=" + value.ToString());
            }
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            if (name == string.Empty)
            {
                throw new ArgumentException(SR.GetString(SR.net_emptystringcall, "name"), "name");
            }

            if (value == string.Empty)
            {
                throw new ArgumentException(SR.GetString(SR.net_emptystringcall, "value"), "name");
            }

            MailBnfHelper.ValidateHeaderName(name);

            // normalize the case of well known headers
            name = MailHeaderInfo.NormalizeCase(name);

            MailHeaderID id = MailHeaderInfo.GetID(name);

            value = value.Normalize(Text.NormalizationForm.FormC);

            if (id == MailHeaderID.ContentType && part != null)
            {
                part.ContentType.Set(value.ToLower(), this);
            }
            else if (id == MailHeaderID.ContentDisposition && part is MimePart)
            {
                ((MimePart)part).ContentDisposition.Set(value.ToLower(), this);
            }
            else
            {
                InternalAdd(name, value);
            }
        }
Пример #7
0
        public override void Set(string name, string value)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (name == string.Empty)
            {
                throw new ArgumentException(SR.Format(SR.net_emptystringcall, nameof(name)), nameof(name));
            }

            if (value == string.Empty)
            {
                throw new ArgumentException(SR.Format(SR.net_emptystringcall, nameof(value)), nameof(name));
            }

            if (!MimeBasePart.IsAscii(name, false))
            {
                throw new FormatException(SR.Format(SR.InvalidHeaderName));
            }

            // normalize the case of well known headers
            name = MailHeaderInfo.NormalizeCase(name);

            MailHeaderID id = MailHeaderInfo.GetID(name);

            // TODO https://github.com/dotnet/corefx/issues/11747: Uncomment once we can use NormalizationForm
            //value = value.Normalize(NormalizationForm.FormC);

            if (id == MailHeaderID.ContentType && _part != null)
            {
                _part.ContentType.Set(value.ToLower(CultureInfo.InvariantCulture), this);
            }
            else if (id == MailHeaderID.ContentDisposition && _part is MimePart)
            {
                ((MimePart)_part).ContentDisposition.Set(value.ToLower(CultureInfo.InvariantCulture), this);
            }
            else
            {
                base.Set(name, value);
            }
        }
        public override void Set(string name, string value)
        {
            if (Logging.On)
            {
                Logging.PrintInfo(Logging.Web, this, "Set", name.ToString() + "=" + value.ToString());
            }
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if (name == string.Empty)
            {
                throw new ArgumentException(SR.GetString("net_emptystringcall", new object[] { "name" }), "name");
            }
            if (value == string.Empty)
            {
                throw new ArgumentException(SR.GetString("net_emptystringcall", new object[] { "value" }), "name");
            }
            if (!MimeBasePart.IsAscii(name, false))
            {
                throw new FormatException(SR.GetString("InvalidHeaderName"));
            }
            name = MailHeaderInfo.NormalizeCase(name);
            MailHeaderID iD = MailHeaderInfo.GetID(name);

            if ((iD == MailHeaderID.ContentType) && (this.part != null))
            {
                this.part.ContentType.Set(value.ToLower(CultureInfo.InvariantCulture), this);
            }
            else if ((iD == MailHeaderID.ContentDisposition) && (this.part is MimePart))
            {
                ((MimePart)this.part).ContentDisposition.Set(value.ToLower(CultureInfo.InvariantCulture), this);
            }
            else
            {
                base.Set(name, value);
            }
        }
Пример #9
0
#pragma warning disable CS8765 // Nullability of parameters 'name' and 'value' don't match overridden member
        public override void Add(string name, string value)
#pragma warning restore CS8765
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            if (name.Length == 0)
            {
                throw new ArgumentException(SR.Format(SR.net_emptystringcall, nameof(name)), nameof(name));
            }
            if (value.Length == 0)
            {
                throw new ArgumentException(SR.Format(SR.net_emptystringcall, nameof(value)), nameof(value));
            }

            MailBnfHelper.ValidateHeaderName(name);

            // normalize the case of well known headers
            name = MailHeaderInfo.NormalizeCase(name);

            MailHeaderID id = MailHeaderInfo.GetID(name);

            value = value.Normalize(NormalizationForm.FormC);

            if (id == MailHeaderID.ContentType && _part != null)
            {
                _part.ContentType.Set(value.ToLowerInvariant(), this);
            }
            else if (id == MailHeaderID.ContentDisposition && _part is MimePart)
            {
                ((MimePart)_part).ContentDisposition !.Set(value.ToLowerInvariant(), this);
            }
            else
            {
                InternalAdd(name, value);
            }
        }
Пример #10
0
        public override void Add(string name, string value)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            if (name == string.Empty)
            {
                throw new ArgumentException(string.Format(Strings.net_emptystringcall, nameof(name)), nameof(name));
            }
            if (value == string.Empty)
            {
                throw new ArgumentException(string.Format(Strings.net_emptystringcall, nameof(value)), nameof(name));
            }

            MailBnfHelper.ValidateHeaderName(name);

            // normalize the case of well known headers
            name = MailHeaderInfo.NormalizeCase(name);

            MailHeaderID id = MailHeaderInfo.GetID(name);

            value = value.Normalize(NormalizationForm.FormC);

            if (id == MailHeaderID.ContentType && _part != null)
            {
                _part.ContentType.Set(value.ToLower(CultureInfo.InvariantCulture), this);
            }
            else if (id == MailHeaderID.ContentDisposition && _part is MimePart)
            {
                ((MimePart)_part).ContentDisposition.Set(value.ToLower(CultureInfo.InvariantCulture), this);
            }
            else
            {
                InternalAdd(name, value);
            }
        }
Пример #11
0
        public override string[] GetValues(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (name == string.Empty)
            {
                throw new ArgumentException(SR.Format(SR.net_emptystringcall, nameof(name)), nameof(name));
            }

            MailHeaderID id = MailHeaderInfo.GetID(name);

            if (id == MailHeaderID.ContentType && _part != null)
            {
                _part.ContentType.PersistIfNeeded(this, false);
            }
            else if (id == MailHeaderID.ContentDisposition && _part is MimePart)
            {
                ((MimePart)_part).ContentDisposition.PersistIfNeeded(this, false);
            }
            return(base.GetValues(name));
        }
Пример #12
0
 public HeaderInfo(MailHeaderID id, string name, bool isSingleton)
 {
     this.ID = id;
     this.NormalizedName = name;
     this.IsSingleton = isSingleton;
 }
Пример #13
0
 internal static bool IsMatch(string name, MailHeaderID header)
 {
     int index;
     return s_headerDictionary.TryGetValue(name, out index) && (MailHeaderID)index == header;
 }
Пример #14
0
 internal static bool IsMatch(string name, MailHeaderID header) {
     int index;
     if(m_HeaderDictionary.TryGetValue(name, out index) && (MailHeaderID)index == header) {
         return true;
     }
     return false;
 }
Пример #15
0
 internal static bool IsMatch(string name, MailHeaderID header)
 {
     int num;
     return (m_HeaderDictionary.TryGetValue(name, out num) && (num == (int)header));
 }
Пример #16
0
 internal static string GetString(MailHeaderID id) {
     switch(id) {
         case MailHeaderID.Unknown:
         case MailHeaderID.ZMaxEnumValue+1:
             return null;
         default:
             return m_HeaderInfo[(int)id].NormalizedName;
     }
 }
Пример #17
0
        internal static bool IsMatch(string name, MailHeaderID header)
        {
            int index;

            return(s_headerDictionary.TryGetValue(name, out index) && (MailHeaderID)index == header);
        }
 public HeaderInfo(MailHeaderID id, string name, bool isSingleton, bool isUserSettable)
 {
     this.ID = id;
     this.NormalizedName = name;
     this.IsSingleton = isSingleton;
     this.IsUserSettable = isUserSettable;
 }
Пример #19
0
        internal static bool IsMatch(string name, MailHeaderID header)
        {
            int num;

            return(m_HeaderDictionary.TryGetValue(name, out num) && (num == (int)header));
        }
Пример #20
0
 public HeaderInfo(MailHeaderID id, string name, bool isSingleton)
 {
     this.ID             = id;
     this.NormalizedName = name;
     this.IsSingleton    = isSingleton;
 }