Esempio n. 1
0
 internal void SetCookie()
 {
     if (!URI.IsNullOrEmpty() && Cookies != null && Cookies.Count > 0)
     {
         Cookies.ForDicEach((key, val) =>
         {
             OptionBuilder.Cookies.Add(new Uri(URI), new Cookie(key, val));
         });
     }
     if (!URI.IsNullOrEmpty() && CookieColl != null && CookieColl.Count > 0)
     {
         OptionBuilder.Cookies.Add(new Uri(URI), CookieColl);
     }
     if (!CookieName.IsNullOrEmpty() && !CookieValue.IsNullOrEmpty() && !CookiePath.IsNullOrEmpty())
     {
         OptionBuilder.Cookies.Add(new Cookie(CookieName, CookieValue, CookiePath, CookieDomain));
     }
 }
Esempio n. 2
0
 internal CookieContainer SetCookie(CookieContainer Container)
 {
     return(SyncStatic.TryCatch(() =>
     {
         if (Container == null)
         {
             Container = new CookieContainer();
         }
         if (InstanceCookie)
         {
             return Container;
         }
         else
         {
             if (!URI.IsNullOrEmpty() && Cookies != null && Cookies.Count > 0)
             {
                 Cookies.ForDicEach((key, val) =>
                 {
                     Container.Add(new Uri(URI), new Cookie(key, val));
                 });
                 return Container;
             }
             else if (!URI.IsNullOrEmpty() && CookieColl != null && CookieColl.Count > 0)
             {
                 Container.Add(new Uri(URI), CookieColl);
                 return Container;
             }
             else if (!CookieName.IsNullOrEmpty() && !CookieValue.IsNullOrEmpty() && !CookiePath.IsNullOrEmpty())
             {
                 Container.Add(new Cookie(CookieName, CookieValue, CookiePath, CookieDomain));
                 return Container;
             }
             else
             {
                 throw new Exception("Cookie配置不满足!");
             }
         }
     }, ex => throw ex));
 }