public override bool Equals(object obj)
        {
            if (Name == null || CookiePath == null || obj == null || !(obj is CookieStatus))
            {
                return(false);
            }
            var bi = (CookieStatus)obj;

            return(Name.Equals(bi.Name) && CookiePath.Equals(bi.CookiePath));
        }
Пример #2
0
    public override string ToString()
    {
        var  sb      = new StringBuilder("SecurityCenterResult(");
        bool __first = true;

        if (Uri != null && __isset.uri)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("Uri: ");
            Uri.ToString(sb);
        }
        if (Token != null && __isset.token)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("Token: ");
            Token.ToString(sb);
        }
        if (CookiePath != null && __isset.cookiePath)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("CookiePath: ");
            CookiePath.ToString(sb);
        }
        if (__isset.skip)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("Skip: ");
            Skip.ToString(sb);
        }
        sb.Append(")");
        return(sb.ToString());
    }
Пример #3
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));
     }
 }
Пример #4
0
    public override int GetHashCode()
    {
        int hashcode = 157;

        unchecked {
            if (__isset.uri)
            {
                hashcode = (hashcode * 397) + Uri.GetHashCode();
            }
            if (__isset.token)
            {
                hashcode = (hashcode * 397) + Token.GetHashCode();
            }
            if (__isset.cookiePath)
            {
                hashcode = (hashcode * 397) + CookiePath.GetHashCode();
            }
            if (__isset.skip)
            {
                hashcode = (hashcode * 397) + Skip.GetHashCode();
            }
        }
        return(hashcode);
    }
#pragma warning disable 1591
        public override int GetHashCode()
        {
            return(CookiePath == null ? 0 : CookiePath.GetHashCode());
        }
Пример #6
0
        void SetHeaders()
        {
            if (IsDataSent)
            {
                return;
            }

            if (StatusCode != null)
            {
                response.StatusCode = (int)StatusCode;
            }

            if (StatusMessage != null)
            {
                response.StatusDescription = StatusMessage;
            }

            if (Chunked != null)
            {
                response.SendChunked = (bool)Chunked;
            }

            if (Headers != null)
            {
                foreach (var header in Headers)
                {
                    response.AppendHeader(header.Key, header.Value);
                }
            }

            if (Cookies != null)
            {
                foreach (var cookie in Cookies)
                {
                    var cookieObj = new Cookie(cookie.Key, cookie.Value);
                    if (CookiePath != null && CookiePath.ContainsKey(cookie.Key))
                    {
                        cookieObj.Path = CookiePath[cookie.Key];
                    }
                    if (CookieExpire != null && CookieExpire.ContainsKey(cookie.Key))
                    {
                        cookieObj.Expires = DateTime.Now.AddSeconds(CookieExpire[cookie.Key]);
                    }
                    response.AppendCookie(cookieObj);
                }
            }

            if (ContentType != null)
            {
                response.ContentType = ContentType;
            }

            if (RedirectLocation != null)
            {
                if (StatusCode == null)
                {
                    response.StatusCode = 302;
                }
                response.RedirectLocation = RedirectLocation;
            }

            if (AllowCors)
            {
                response.AppendHeader("Access-Control-Expose-Headers", String.Join(", ", response.Headers.AllKeys));
                response.AppendHeader("Access-Control-Allow-Origin", "*");
            }

            IsDataSent = true;
        }
Пример #7
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));
 }