Exemplo n.º 1
0
        internal int IndexOf(Cookie cookie)
        {
            IComparer comp = Cookie.GetComparer();
            int       idx  = 0;

            foreach (Cookie c in m_list)
            {
                if (comp.Compare(cookie, c) == 0)
                {
                    return(idx);
                }
                ++idx;
            }
            return(-1);
        }
Exemplo n.º 2
0
        internal int IndexOf(Cookie cookie)
        {
            IComparer comparer = Cookie.GetComparer();
            int       num      = 0;

            foreach (Cookie cookie2 in this.m_list)
            {
                if (comparer.Compare(cookie, cookie2) == 0)
                {
                    return(num);
                }
                num++;
            }
            return(-1);
        }
Exemplo n.º 3
0
        // If isStrict == false, assumes that incoming cookie is unique
        // If isStrict == true, replace the cookie if found same with newest Variant
        // returns 1 if added, 0 if replaced or rejected
        internal int InternalAdd(Cookie cookie, bool isStrict)
        {
            int ret = 1;

            if (isStrict)
            {
                IComparer comp = Cookie.GetComparer();
                int       idx  = 0;
                foreach (Cookie c in m_list)
                {
                    if (comp.Compare(cookie, c) == 0)
                    {
                        ret = 0;    //will replace or reject
                        //Cookie2 spec requires that new Variant cookie overwrite the old one
                        if (c.Variant <= cookie.Variant)
                        {
                            m_list[idx] = cookie;
                        }
                        break;
                    }
                    ++idx;
                }

                if (idx == m_list.Count)
                {
                    m_list.Add(cookie);
                }
            }
            else
            {
                m_list.Add(cookie);
            }


            if (cookie.Version != Cookie.MaxSupportedVersion)
            {
                m_has_other_versions = true;
            }
            return(ret);
        }
Exemplo n.º 4
0
        internal int InternalAdd(Cookie cookie, bool isStrict)
        {
            int num = 1;

            if (!isStrict)
            {
                this.m_list.Add(cookie);
            }
            else
            {
                IComparer comparer = Cookie.GetComparer();
                int       num2     = 0;
                foreach (Cookie cookie2 in this.m_list)
                {
                    if (comparer.Compare(cookie, cookie2) == 0)
                    {
                        num = 0;
                        if (cookie2.Variant <= cookie.Variant)
                        {
                            this.m_list[num2] = cookie;
                        }
                        break;
                    }
                    num2++;
                }
                if (num2 == this.m_list.Count)
                {
                    this.m_list.Add(cookie);
                }
            }
            if (cookie.Version != 1)
            {
                this.m_has_other_versions = true;
            }
            return(num);
        }