Compare() статический приватный Метод

static private Compare ( Cookie left, Cookie right ) : int
left Cookie
right Cookie
Результат int
Пример #1
0
        internal int IndexOf(Cookie cookie)
        {
            int idx = 0;

            foreach (Cookie c in _list)
            {
                if (CookieComparer.Compare(cookie, c) == 0)
                {
                    return(idx);
                }
                ++idx;
            }
            return(-1);
        }
Пример #2
0
        internal int InternalAdd(Cookie cookie, bool isStrict)
        {
            int ret = 1;

            if (isStrict)
            {
                int idx       = 0;
                int listCount = m_list.Count;
                for (int i = 0; i < listCount; i++)
                {
                    Cookie c = (Cookie)m_list[i] !;
                    if (CookieComparer.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);
        }
Пример #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)
            {
                CookieComparer comp = CookieComparer.Instance;

                int idx = 0;
                foreach (Cookie c in _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)
                        {
                            _list[idx] = cookie;
                        }
                        break;
                    }
                    ++idx;
                }
                if (idx == _list.Count)
                {
                    _list.Add(cookie);
                }
            }
            else
            {
                _list.Add(cookie);
            }
            if (cookie.Version != Cookie.MaxSupportedVersion)
            {
                _hasOtherVersions = true;
            }
            return(ret);
        }