Ejemplo n.º 1
0
 internal static HeaderId GetHeaderId(string name, bool validateArgument)
 {
     if (name == null)
     {
         if (validateArgument)
         {
             throw new ArgumentNullException("name");
         }
         return(HeaderId.Unknown);
     }
     else
     {
         if (name.Length != 0)
         {
             if (validateArgument)
             {
                 for (int i = 0; i < name.Length; i++)
                 {
                     if (name[i] >= '\u0080' || !MimeScan.IsField((byte)name[i]))
                     {
                         throw new ArgumentException(Strings.InvalidHeaderName(name, i), "name");
                     }
                 }
             }
             HeaderNameIndex headerNameIndex = Header.LookupName(name);
             return(MimeData.headerNames[(int)headerNameIndex].publicHeaderId);
         }
         if (validateArgument)
         {
             throw new ArgumentException("Header name cannot be an empty string", "name");
         }
         return(HeaderId.Unknown);
     }
 }
Ejemplo n.º 2
0
 public static bool IsHeaderNameValid(string name)
 {
     if (string.IsNullOrEmpty(name))
     {
         return(false);
     }
     for (int i = 0; i < name.Length; i++)
     {
         if (name[i] >= '\u0080' || !MimeScan.IsField((byte)name[i]))
         {
             return(false);
         }
     }
     return(true);
 }