Exemplo n.º 1
0
 public static void InsertHeaderFieldIfNeed(StringCollection source, string name, string theValue)
 {
     if (!StringUtils.IsEmpty(theValue))
     {
         HeaderFieldList fieldList = new HeaderFieldList();
         int             index     = GetHeaderFieldList(0, source, fieldList);
         if (!fieldList.ContainsField(name))
         {
             if ((index < 0) || (index > source.Count))
             {
                 index = source.Count;
             }
             theValue = theValue.Replace("\r\n", "\r\n\t");
             if (theValue[theValue.Length - 1] == '\t')
             {
                 theValue = theValue.Substring(0, theValue.Length - 1);
             }
             foreach (string str in StringUtils.GetStringArray(string.Format("{0}: {1}", name, theValue)))
             {
                 source.Insert(index, str);
                 index++;
             }
         }
     }
 }